[469] | 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 | function XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt) |
---|
[672] | 12 | SubDirBase=SubDir; |
---|
| 13 | XmlFileName=fullfile(RootPath,[SubDir '.xml']); |
---|
| 14 | if ~exist (XmlFileName,'file') |
---|
| 15 | dotchar=regexp(SubDir,'\.'); |
---|
| 16 | for idot=1:numel(dotchar) |
---|
[674] | 17 | XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)-1) '.xml']); |
---|
[672] | 18 | if exist(XmlFileName,'file') |
---|
[701] | 19 | SubDirBase=fullfile(RootPath,SubDir(1:dotchar(end-idot+1)-1)); |
---|
[672] | 20 | break |
---|
| 21 | end |
---|
| 22 | end |
---|
| 23 | end |
---|
[469] | 24 | if ~exist(XmlFileName,'file') |
---|
[507] | 25 | XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.xml']; % old convention: xml inside the image folder, case of images or new civ files |
---|
[469] | 26 | if ~exist(XmlFileName,'file') |
---|
[507] | 27 | XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.civ']; % very old convention: .civ file |
---|
| 28 | if ~exist(XmlFileName,'file') && strcmp(FileExt,'.nc') |
---|
| 29 | XmlFileName=[fullfile(RootPath,RootFile) '.xml'] ; % old convention: xml inside the image folder, old civ file opened |
---|
| 30 | if ~exist(XmlFileName,'file') |
---|
| 31 | XmlFileName=[fullfile(RootPath,RootFile) '.civ']; % very old convention: .civ file |
---|
| 32 | end |
---|
[469] | 33 | end |
---|
| 34 | end |
---|
[507] | 35 | end |
---|
[737] | 36 | if exist(XmlFileName,'file')~=2 |
---|
[507] | 37 | XmlFileName=''; |
---|
[469] | 38 | end |
---|