Ignore:
Timestamp:
Jun 26, 2024, 6:37:49 PM (4 months ago)
Author:
sommeria
Message:

civ_3D updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/update_imadoc.m

    r1127 r1151  
    3030errormsg='';
    3131testappend=0;
    32 %% backup the output file if it already exist, and read it
    33 if exist(outputfile,'file')%=1 if the output file already exists, 0 else
    34     testappend=1;
    35     backupfile=outputfile;
    36     t=xmltree(outputfile); %read the file
    37     title=get(t,1,'name');
    38     if strcmp(title,'ImaDoc')
    39         %         testappend=1;
    40         %rename the existing file for backup
    41         testexist=2;
     32
     33%% set the output xml file at the root, hide other existing  xml files
     34dotchar=regexp(outputfile,'\.');
     35for idot=1:numel(dotchar)
     36    outputfile=[outputfile(1:dotchar(end-idot+1)-1) '.xml'];
     37    if exist(outputfile,'file')
     38         backupfile=outputfile;
     39         testexist=2;
    4240        while testexist==2
    4341            backupfile=[backupfile '~'];
     
    4947            return
    5048        end
    51         %if the xml file is  ImaDoc
    52         uid_calib=find(t,['ImaDoc/' StructName]);
    53         if isempty(uid_calib)  %if Struct does not already exists, create it
    54             [t,uid_calib]=add(t,1,'element',StructName);
    55         else %if Struct already exists, delete its content
    56             uid_child=children(t,uid_calib);
    57             t=delete(t,uid_child);
    58         end
     49    end
     50end
     51
     52
     53%% backup the output file if it already exist, and read it
     54if exist(outputfile,'file')%=1 if the output file already exists, 0 else
     55    testappend=1;
     56    t=xmltree(outputfile); %read the file
     57    title=get(t,1,'name');
     58    if ~strcmp(title,'ImaDoc')
     59        errormsg=[outputfile ' not appropriate for calibration'];
     60        return
     61    end
     62    uid_calib=find(t,['ImaDoc/' StructName]);
     63    if isempty(uid_calib)  %if Struct does not already exists, create it
     64        [t,uid_calib]=add(t,1,'element',StructName);
     65    else %if Struct already exists, delete its content
     66        uid_child=children(t,uid_calib);
     67        t=delete(t,uid_child);
    5968    end
    6069end
Note: See TracChangeset for help on using the changeset viewer.