Changeset 1022 for trunk/src/uigetfile_uvmat.m
- Timestamp:
- Dec 11, 2017, 1:15:03 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uigetfile_uvmat.m
r977 r1022 48 48 InputFileName='';%default 49 49 if ischar(InputName) 50 if exist(InputName,'dir') 51 InputDir=InputName; 52 InputFileName=''; 53 elseif exist(InputName,'file') 54 [InputDir,InputFileName,Ext]=fileparts(InputName); 55 if isempty(InputFileName)% if InputName is already the root 56 InputFileName=InputDir; 57 if ~isempty(strcmp (computer, {'PCWIN','PCWIN64'}))%case of Windows systems 58 % InputDir=[InputDir '\'];% append '\' for a correct action of dir 59 InputFileName=[InputFileName '\']; 50 if isempty(regexp(InputName,'^http://'))%usual files 51 if exist(InputName,'dir') 52 InputDir=InputName; 53 InputFileName=''; 54 elseif exist(InputName,'file') 55 [InputDir,InputFileName,Ext]=fileparts(InputName); 56 if isempty(InputFileName)% if InputName is already the root 57 InputFileName=InputDir; 58 if ~isempty(strcmp (computer, {'PCWIN','PCWIN64'}))%case of Windows systems 59 % InputDir=[InputDir '\'];% append '\' for a correct action of dir 60 InputFileName=[InputFileName '\']; 61 end 62 end 63 if isdir(InputName) 64 InputFileName=['+/' InputFileName Ext]; 60 65 end 61 66 end 62 if isdir(InputName)63 Input FileName=['+/' InputFileName Ext];67 if ismember(computer,{'PCWIN','PCWIN64'})%case of Windows systems 68 InputDir=[InputDir '\'];% append '\' for a correct action of dir 64 69 end 65 e nd66 end 67 if ismember(computer,{'PCWIN','PCWIN64'})%case of Windows systems 68 InputDir=[InputDir '\'];% append '\' for a correct action of dir 69 end 70 else 71 [InputDir,InputFileName,Ext]=fileparts(InputName); 72 end 73 end 74 70 75 hfig=findobj(allchild(0),'tag',option); 71 76 if isempty(hfig) … … 147 152 htitlebox=findobj(hfig,'tag','titlebox'); % display the current dir name 148 153 DirName=get(htitlebox,'String'); 149 if isempty(regexp(DirName,'^http://'))% if the input dir is not a web site (begins by http://)150 % FullSelectName=DirName;151 % else152 154 if ~strcmp(filter_ext,'uigetdir')% a file is expected as output, not a dir 153 155 hlist=findobj(hfig,'Tag','list'); … … 163 165 SelectName=SelectName(1:ind_dot-1); 164 166 end 165 FullSelectName=fullfile(DirName,SelectName); 166 % if regexp(DirName,'^http://')% if the input dir is a web site (begins by http://) 167 168 if exist(FullSelectName,'file') 167 if isempty(regexp(DirName,'^http://'))% if the input dir is not a web site (begins by http://) 168 FullSelectName=fullfile(DirName,SelectName); 169 check_exist=exist(FullSelectName,'file'); 170 else 171 FullSelectName=[DirName '/' SelectName]; 172 check_exist=1; 173 end 174 if check_exist 169 175 switch option 170 176 case 'browser' … … 185 191 end 186 192 end 187 end188 193 set(hObject,'backgroundColor',[0 1 0])% indicate end button activation 189 194 uiresume(get(hObject,'parent')) 190 195 191 %------------------------------------------------------------------------ 196 %------------------------------------------------------------------------ 192 197 % --- launched by refreshing the display figure 193 198 function refresh_GUI(hObject,InputFileName,FilterExt) … … 209 214 DirName=get(htitlebox,'String'); 210 215 hsort_option=findobj(hfig,'tag','sort_option'); 211 if strcmp(get(hfig,'Tag'),'status_display') 216 % use with GUI series 217 if strcmp(get(hfig,'Tag'),'status_display') % use with GUI series 212 218 hseries=findobj(allchild(0),'tag','series'); 213 219 hstatus=findobj(hseries,'tag','status'); … … 218 224 end 219 225 hlist=findobj(hfig,'tag','list'); 220 testrecent=0; 226 testrecent=0; 221 227 NbOutputFile=[]; 222 228 if isfield(StatusData,'NbOutputFile') … … 226 232 [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content 227 233 228 % %update the waitbar234 % update the waitbar 229 235 hwaitbar=findobj(hfig,'tag','waitbar'); 230 236 if ~isempty(NbOutputFile) … … 233 239 set(hwaitbar,'Position',BarPosition) 234 240 end 235 else 241 else %use as usual browser 236 242 sort_option='name'; 237 243 if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) … … 281 287 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 282 288 DirName=get(htitlebox,'String'); 289 CheckSubDir=~isempty(regexp(list{index},'^\+')); 283 290 SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir 284 291 ind_dot=regexp(SelectName,'\s*\.\.\.');%remove what is beyond '...' … … 289 296 FullSelectName=fileparts(DirName); 290 297 else 291 FullSelectName=fullfile(DirName,SelectName); 292 end 293 if exist(FullSelectName,'dir')% a directory has been selected 298 if isempty(regexp(DirName,'^http://'))% usual files 299 FullSelectName=fullfile(DirName,SelectName); 300 else 301 FullSelectName=[DirName '/' SelectName]; 302 end 303 end 304 if CheckSubDir%exist(FullSelectName,'dir')% a directory has been selected 294 305 set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action 295 306 drawnow … … 315 326 function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option,filter_ext) 316 327 %------------------------------------------------------------------------- 317 ListStruct=dir (DirName);% get structure of the current directory328 ListStruct=dir_uvmat(DirName);% get structure of the current directory 318 329 NumFiles=0; %default 319 330 if numel(ListStruct)<1 % case of empty dir 320 % if regexp(DirName,'^http://')% if the input dir is a web site (begins by http://)321 % web(DirName)322 % else323 331 ListFiles={}; 324 332 return 325 % end326 333 end 327 334 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 328 335 ListFiles=ListCells(1,:);%list of file names 329 336 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 337 % for ilist=1:numel(check_dir) 338 % if check_dir(ilist) 330 339 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 340 % end 341 % end 331 342 if exist('filter_ext','var') && ~strcmp(filter_ext,'*') &&~strcmp(filter_ext,'uigetdir') 332 343 if strcmp(filter_ext,'image')
Note: See TracChangeset
for help on using the changeset viewer.