source: trunk/src/find_imadoc.m @ 887

Last change on this file since 887 was 809, checked in by g7moreau, 10 years ago
  • Add license
File size: 2.5 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%=======================================================================
13% Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF 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
[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
[737]55if exist(XmlFileName,'file')~=2
[507]56    XmlFileName='';
[809]57end
Note: See TracBrowser for help on using the repository browser.