source: trunk/src/find_imadoc.m @ 672

Last change on this file since 672 was 672, checked in by sommeria, 8 years ago

various bugs corrected

File size: 1.8 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
11function XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt)
12SubDirBase=SubDir;
13XmlFileName=fullfile(RootPath,[SubDir '.xml']);
14if ~exist (XmlFileName,'file')
15    dotchar=regexp(SubDir,'\.');
16    for idot=1:numel(dotchar)
17        XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)) '.xml']);
18        if exist(XmlFileName,'file')
19            SubDirBase=fullfile(RootPath,SubDir(1:dotchar(end-idot+1)));
20            break
21        end
22    end   
23end
24% SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
25% XmlFileName=[fullfile(RootPath,SubDirBase) '.xml'];%new convention: xml at the level of the image folder
26if ~exist(XmlFileName,'file')
27    XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.xml']; % old convention: xml inside the image folder, case of images or new civ files
28    if ~exist(XmlFileName,'file')
29        XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.civ']; % very old convention: .civ file
30        if ~exist(XmlFileName,'file') && strcmp(FileExt,'.nc')
31            XmlFileName=[fullfile(RootPath,RootFile) '.xml'] ; % old convention: xml inside the image folder, old civ file opened
32            if ~exist(XmlFileName,'file')
33                XmlFileName=[fullfile(RootPath,RootFile) '.civ']; % very old convention: .civ file
34            end
35        end
36    end
37end
38if ~exist(XmlFileName,'file')
39    XmlFileName='';
40end
Note: See TracBrowser for help on using the repository browser.