Changeset 1090 for trunk/src/browse_data.m
- Timestamp:
- Jan 21, 2021, 3:59:54 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/browse_data.m
r1076 r1090 153 153 set(handles.SourceDir,'BackgroundColor',[1 1 0])% indicate action of button by yellow color 154 154 drawnow 155 SourceDir=get(handles.SourceDir,'String'); 156 [SourcePath,ProjectName]=fileparts(SourceDir); 155 SourcePath=get(handles.SourceDir,'String'); 156 if ~isempty(regexp(SourcePath,'^http')) 157 SourcePath=pwd; 158 SourcePath=regexprep(SourcePath,'^\/.fsnet','/fsnet'); 159 end 160 161 162 ProjectList=get(handles.ListExperiments,'String'); 163 ProjectName=ProjectList{get(handles.ListExperiments,'Value')}; 164 ProjectName=regexprep(ProjectName,'^\+/',''); 157 165 if strcmp(get(handles.MirrorDir,'Visible'),'on') 158 MirrorDir=get(handles.MirrorDir,'String');% name of the mirror folder166 MirrorDir=get(handles.MirrorDir,'String');% name of the mirror folder 159 167 else% create the mirror folder if it does not exist 160 MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir'); 161 if isempty(MirrorRoot) 162 return 163 elseif strcmp(MirrorRoot,SourcePath) 164 msgbox_uvmat('ERROR','The mirror folder must be different from the source') 165 return 166 else 167 MirrorDir=fullfile(MirrorRoot,ProjectName); 168 end 169 if exist(MirrorDir,'dir') 170 msgbox_uvmat('ERROR',['The folder ' MirrorDir ' chosen as new mirror campaign already exists']) 171 return 172 else 173 [s,errormsg]=mkdir(MirrorDir)% create the mirror dir 174 if s~=1 175 msgbox_uvmat('ERROR',['error in creating ' MirrorDir ': ' errormsg]) 176 return 177 end 178 end 179 MirrorDoc.SourceDir=SourceDir; 180 t=struct2xml(MirrorDoc); 181 set(t,1,'name','DataTree'); 182 save(t,fullfile(MirrorDir,[ProjectName '.xml']))% create an xml file in the mirror folder to indicate its source folder 183 set(handles.MirrorDir,'String',MirrorDir) 184 set(handles.MirrorDir,'Visible','on') 185 set(handles.CreateMirror,'String','update_mirror') 168 MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir'); 169 if isempty(MirrorRoot) 170 return 171 elseif strcmp(MirrorRoot,SourcePath) 172 msgbox_uvmat('ERROR','The mirror folder must be different from the source') 173 return 174 else 175 MirrorDir=fullfile(MirrorRoot,ProjectName); 176 end 177 if exist(MirrorDir,'dir') 178 msgbox_uvmat('ERROR',['The folder ' MirrorDir ' chosen as new mirror campaign already exists']) 179 return 180 else 181 [s,errormsg]=mkdir(MirrorDir);% create the mirror dir 182 if s~=1 183 msgbox_uvmat('ERROR',['error in creating ' MirrorDir ': ' errormsg]) 184 return 185 end 186 end 187 SourceDir=fullfile(SourcePath,ProjectName); 188 MirrorDoc.SourceDir=SourceDir; 189 t=struct2xml(MirrorDoc); 190 set(t,1,'name','DataTree'); 191 save(t,fullfile(MirrorDir,[ProjectName '.xml']))% create an xml file in the mirror folder to indicate its source folder 192 set(handles.MirrorDir,'String',MirrorDir) 193 set(handles.MirrorDir,'Visible','on') 194 set(handles.CreateMirror,'String','update_mirror') 186 195 end 187 196 ExpName={''}; … … 189 198 %% update the mirror from the source dir 190 199 if exist(SourceDir,'dir') 191 hdir=dir(SourceDir); %list files and dirs192 idir=0;193 for ilist=1:length(hdir)194 if hdir(ilist).isdir% scan all subfolders195 dirname=hdir(ilist).name;%196 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')%skip subfolder beginning by '0'197 idir=idir+1;198 mirror=fullfile(MirrorDir,hdir(ilist).name);% corresponding name in the mirror199 if ~exist(mirror,'dir')200 mkdir(mirror)% create the mirror folder if it does not exist201 end202 ExpName{idir}=['+/' hdir(ilist).name];% insert '+/' in the list to show that it is a folder203 end204 % look for the list of 'devices'205 else206 %warning for isolated files207 end208 end209 set(handles.ListExperiments,'String',[{'*'};ExpName'])210 set(handles.ListExperiments,'Value',1)211 update_experiments(handles,[{'*'};ExpName'],SourceDir,MirrorDir)212 % ListExperiments_Callback(hObject, eventdata, handles) % list the content of the experiment213 else 214 msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory'])200 hdir=dir(SourceDir); %list files and dirs 201 idir=0; 202 for ilist=1:length(hdir) 203 if hdir(ilist).isdir% scan all subfolders 204 dirname=hdir(ilist).name;% 205 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')%skip subfolder beginning by '0' 206 idir=idir+1; 207 mirror=fullfile(MirrorDir,hdir(ilist).name);% corresponding name in the mirror 208 if ~exist(mirror,'dir') 209 mkdir(mirror)% create the mirror folder if it does not exist 210 end 211 ExpName{idir}=['+/' hdir(ilist).name];% insert '+/' in the list to show that it is a folder 212 end 213 % look for the list of 'devices' 214 else 215 %warning for isolated files 216 end 217 end 218 set(handles.ListExperiments,'String',[{'*'};ExpName']) 219 set(handles.ListExperiments,'Value',1) 220 update_experiments(handles,[{'*'};ExpName'],SourceDir,MirrorDir) 221 % ListExperiments_Callback(hObject, eventdata, handles) % list the content of the experiment 222 else 223 msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory']) 215 224 end 216 225 set(handles.SourceDir,'BackgroundColor',[1 1 1])
Note: See TracChangeset
for help on using the changeset viewer.