Ignore:
Timestamp:
Jul 23, 2012, 8:44:33 PM (12 years ago)
Author:
sommeria
Message:

various bug corrections, compatibilty with older PIV data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/update_imadoc.m

    r414 r498  
    1010errormsg='';
    1111testappend=0;
    12 if exist(outputfile,'file');%=1 if the output file already exists, 0 else 
     12%% backup the output file if it already exist, and read it
     13if exist(outputfile,'file');%=1 if the output file already exists, 0 else
    1314    testappend=1;
    14     t=xmltree(outputfile); %read the file
    1515    backupfile=outputfile;
    1616    testexist=2;
    1717    while testexist==2
    18        backupfile=[backupfile '~'];
    19        testexist=exist(backupfile,'file');
     18        backupfile=[backupfile '~'];
     19        testexist=exist(backupfile,'file');
    2020    end
    2121    [success,message]=copyfile(outputfile,backupfile);%make backup
    22     if success==0
    23         errormsg=message;
     22    if success~=1
     23        errormsg=['errror in xml file backup: ' message];
     24        return
    2425    end
    25     uid=find(t,'ImaDoc');
    26     if ~isequal(uid,1)
    27         return
    28     end       
    29     %if the xml file is  ImaDoc
    30     uid_calib=find(t,'ImaDoc/GeometryCalib');
    31     if isempty(uid_calib)  %if GeometryCalib does not already exists, create it
    32         [t,uid_calib]=add(t,1,'element','GeometryCalib');
    33     else %if GeometryCalib already exists, delete its content
    34         if isequal(success,1)
    35             delete(outputfile)
    36         else
    37             return
     26    t=xmltree(outputfile); %read the file
     27    title=get(t,1,'name');
     28    if strcmp(title,'ImaDoc'))
     29        testappend=1;
     30        %if the xml file is  ImaDoc
     31        uid_calib=find(t,'ImaDoc/GeometryCalib');
     32        if isempty(uid_calib)  %if GeometryCalib does not already exists, create it
     33            [t,uid_calib]=add(t,1,'element','GeometryCalib');
     34        else %if GeometryCalib already exists, delete its content
     35            uid_child=children(t,uid_calib);
     36            t=delete(t,uid_child);
    3837        end
    39         uid_child=children(t,uid_calib);
    40         t=delete(t,uid_child);
    4138    end
    4239end
    43 %create a new xml file
     40
     41%% create a new xml file
    4442if ~testappend
    4543    t=xmltree;
     
    6967    [t,uid_calib]=add(t,1,'element','GeometryCalib');
    7068end
     69
     70%% save the output file
    7171t=struct2xml(GeometryCalib,t,uid_calib);
    7272save(t,outputfile);
Note: See TracChangeset for help on using the changeset viewer.