source: trunk/src/find_imadoc.m @ 1092

Last change on this file since 1092 was 1071, checked in by g7moreau, 5 years ago
  • Update COPYRIGHT
File size: 3.0 KB
Line 
1% 'find_imadoc': find the ImaDoc xml file associated with a given input file
2% take into account the old conventions
3%-----------------------------------------------------------------------
4% function XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt)
5%
6% OUTPUT:
7% XmlFileName: name of the xml file, ='' if none is found
8%
9% INPUT:
10% RootPath,SubDir,RootFile,FileExt, as given from the input file name by fileparts_uvmat
11
12%=======================================================================
13% Copyright 2008-2020, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
14%   http://www.legi.grenoble-inp.fr
15%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
16%
17%     This file is part of the toolbox UVMAT.
18%
19%     UVMAT is free software; you can redistribute it and/or modify
20%     it under the terms of the GNU General Public License as published
21%     by the Free Software Foundation; either version 2 of the license,
22%     or (at your option) any later version.
23%
24%     UVMAT is distributed in the hope that it will be useful,
25%     but WITHOUT ANY WARRANTY; without even the implied warranty of
26%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27%     GNU General Public License (see LICENSE.txt) for more details.
28%=======================================================================
29
30function XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt)
31SubDirBase=SubDir;
32XmlFileName=fullfile(RootPath,[SubDir '.xml']);
33if ~exist (XmlFileName,'file')
34    dotchar=regexp(SubDir,'\.');
35    for idot=1:numel(dotchar)
36        XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)-1) '.xml']);
37        if exist(XmlFileName,'file')
38            SubDirBase=fullfile(RootPath,SubDir(1:dotchar(end-idot+1)-1));
39            break
40        end
41    end   
42end
43if ~exist(XmlFileName,'file')
44    XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.xml']; % old convention: xml inside the image folder, case of images or new civ files
45    if ~exist(XmlFileName,'file')
46        XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.civ']; % very old convention: .civ file
47        if ~exist(XmlFileName,'file') && strcmp(FileExt,'.nc')
48            XmlFileName=[fullfile(RootPath,RootFile) '.xml'] ; % old convention: xml inside the image folder, old civ file opened
49            if ~exist(XmlFileName,'file')
50                XmlFileName=[fullfile(RootPath,RootFile) '.civ']; % very old convention: .civ file
51            end
52        end
53    end
54end
55if ~exist(XmlFileName,'file')% convention Pierre Augier for 3D images
56    check3D=find(~isempty(regexp(SubDirBase,'^level')));
57    if check3D
58        [RootRootPath,RootDir]=fileparts(RootPath);
59        XmlFileName=fullfile(RootRootPath,[RootDir '.xml']);
60        dotchar=regexp(RootDir,'\.');
61        for idot=1:numel(dotchar)
62            XmlFileName=fullfile(RootRootPath,[RootDir(1:dotchar(end-idot+1)-1) '.xml']);
63            if exist(XmlFileName,'file')
64                break
65            end
66        end
67    end
68end
69if exist(XmlFileName,'file')~=2
70    XmlFileName='';
71end
Note: See TracBrowser for help on using the repository browser.