source: trunk/src/find_imadoc.m @ 985

Last change on this file since 985 was 977, checked in by g7moreau, 7 years ago
  • Update Copyright 2008-2017 notice
File size: 3.0 KB
RevLine 
[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
[809]11
12%=======================================================================
[977]13% Copyright 2008-2017, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
[809]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
[469]30function XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt)
[672]31SubDirBase=SubDir;
32XmlFileName=fullfile(RootPath,[SubDir '.xml']);
33if ~exist (XmlFileName,'file')
34    dotchar=regexp(SubDir,'\.');
35    for idot=1:numel(dotchar)
[674]36        XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)-1) '.xml']);
[672]37        if exist(XmlFileName,'file')
[701]38            SubDirBase=fullfile(RootPath,SubDir(1:dotchar(end-idot+1)-1));
[672]39            break
40        end
41    end   
42end
[469]43if ~exist(XmlFileName,'file')
[507]44    XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.xml']; % old convention: xml inside the image folder, case of images or new civ files
[469]45    if ~exist(XmlFileName,'file')
[507]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
[469]52        end
53    end
[507]54end
[952]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
[737]69if exist(XmlFileName,'file')~=2
[507]70    XmlFileName='';
[809]71end
Note: See TracBrowser for help on using the repository browser.