Changeset 741 for trunk/src/browse_data.m
- Timestamp:
- Apr 15, 2014, 9:06:46 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/browse_data.m
r733 r741 72 72 set(hObject, 'Units', OldUnits); 73 73 if exist('Campaign','var') 74 [ CampaignPath,CampaignName]=fileparts(Campaign);74 [tild,CampaignName]=fileparts(Campaign); 75 75 RootXml=fullfile(Campaign,[CampaignName '.xml']); 76 76 s=[]; … … 125 125 if isempty(MirrorRoot) 126 126 return 127 elseif strcmp(MirrorRoot,SourcePath) 128 msgbox_uvmat('ERROR','The mirror folder must be different from the source') 129 return 127 130 else 128 131 MirrorDir=fullfile(MirrorRoot,ProjectName); 129 132 end 130 if ~exist(MirrorDir,'dir') 131 mkdir(MirrorDir) 133 if exist(MirrorDir,'dir') 134 msgbox_uvmat('ERROR',['The folder ' MirrorDir ' chosen as new mirror campaign already exists']) 135 return 136 else 137 [s,errormsg]=mkdir(MirrorDir)% create the mirror dir 138 if s~=1 139 msgbox_uvmat('ERROR',['error in creating ' MirrorDir ': ' errormsg]) 140 return 141 end 132 142 end 133 143 MirrorDoc.SourceDir=SourceDir; 134 144 t=struct2xml(MirrorDoc); 135 145 set(t,1,'name','DataTree'); 136 save(t,fullfile(MirrorDir,[ProjectName '.xml'])) 146 save(t,fullfile(MirrorDir,[ProjectName '.xml']))% create an xml file in the mirror folder to indicate its source folder 137 147 set(handles.MirrorDir,'String',MirrorDir) 138 148 set(handles.MirrorDir,'Visible','on') 149 set(handles.CreateMirror,'String','update_mirror') 139 150 end 140 151 ExpName={''}; … … 206 217 function ListExperiments_Callback(hObject, eventdata, handles) 207 218 208 MirrorPath='';209 CampaignPath=get(handles.SourceDir,'String');210 219 if strcmp(get(handles.MirrorDir,'Visible'),'on') 211 220 MirrorPath=get(handles.MirrorDir,'String'); 221 else 222 MirrorPath=get(handles.SourceDir,'String'); 212 223 end 213 224 ListExperiments=get(handles.ListExperiments,'String'); … … 229 240 for iexp=1:numel(ListExperiments) 230 241 if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory 231 ListExperiments{iexp}(1)=[]; 242 ListExperiments{iexp}(1)=[];%remove the first char '+' used to mark folders 232 243 ListStruct=dir(fullfile(MirrorPath,ListExperiments{iexp})); %list files and dir in the source experiment directory 233 244 ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray … … 279 290 if ~isempty(MirrorPath) 280 291 mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist}); 281 if exist(mirror,' dir')||exist(mirror,'file')292 if exist(mirror,'file')% if mirror already exists as a file or folder 282 293 [tild,msg]=fileattrib(mirror); 283 294 if strcmp(msg.Name,mirror)%if the mirror name already exists as a local file or dir 284 if msg.directory% case of a f 295 if msg.directory% case of a folder 285 296 answer=msgbox_uvmat('INPUT_Y-N',['replace local folder ' msg.Name ' by a link to the source dir']); 286 297 if strcmp(answer,'Yes') … … 292 303 end 293 304 end 294 else 305 else % case of an existing mirror file 295 306 answer=msgbox_uvmat('INPUT_Y-N',['replace local file ' msg.Name ' by a link to the source file']); 296 307 if strcmp(answer,'Yes') 297 308 delete(mirror); 298 system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder 299 309 system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder 300 310 end 301 311 end 302 else% create mirror to the data series if needed303 system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder304 312 end 313 else% create mirror to the data series if needed 314 system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder 305 315 end 306 316 if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices … … 586 596 Device=Device(Value); 587 597 Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir 598 Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link 588 599 handles.output.Experiment=Experiment; 589 600 handles.output.DataSeries=Device;
Note: See TracChangeset
for help on using the changeset viewer.