Ignore:
Timestamp:
Dec 11, 2017, 1:15:03 AM (7 years ago)
Author:
sommeria
Message:

opendap reading intreoduced

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uigetfile_uvmat.m

    r977 r1022  
    4848InputFileName='';%default
    4949if 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];
    6065            end
    6166        end
    62         if isdir(InputName)
    63             InputFileName=['+/' InputFileName Ext];
     67        if  ismember(computer,{'PCWIN','PCWIN64'})%case of Windows systems
     68            InputDir=[InputDir '\'];% append '\' for a correct action of dir
    6469        end
    65     end
    66 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
     73end
     74
    7075hfig=findobj(allchild(0),'tag',option);
    7176if isempty(hfig)
     
    147152htitlebox=findobj(hfig,'tag','titlebox');  % display the current dir name 
    148153DirName=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 % else
    152154if ~strcmp(filter_ext,'uigetdir')% a file is expected as output, not a dir
    153155    hlist=findobj(hfig,'Tag','list');
     
    163165        SelectName=SelectName(1:ind_dot-1);
    164166    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
    169175        switch option
    170176            case 'browser'
     
    185191    end
    186192end
    187 end
    188193set(hObject,'backgroundColor',[0 1 0])% indicate end button activation
    189194uiresume(get(hObject,'parent'))
    190195
    191 %------------------------------------------------------------------------   
     196%------------------------------------------------------------------------
    192197% --- launched by refreshing the display figure
    193198function refresh_GUI(hObject,InputFileName,FilterExt)
     
    209214DirName=get(htitlebox,'String');
    210215hsort_option=findobj(hfig,'tag','sort_option');
    211 if strcmp(get(hfig,'Tag'),'status_display')
     216% use with GUI series
     217if strcmp(get(hfig,'Tag'),'status_display') % use with GUI series
    212218    hseries=findobj(allchild(0),'tag','series');
    213219    hstatus=findobj(hseries,'tag','status');
     
    218224    end
    219225    hlist=findobj(hfig,'tag','list');
    220     testrecent=0;   
     226    testrecent=0;
    221227    NbOutputFile=[];
    222228    if isfield(StatusData,'NbOutputFile')
     
    226232    [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content
    227233   
    228     %% update the waitbar
     234    % update the waitbar
    229235    hwaitbar=findobj(hfig,'tag','waitbar');
    230236    if ~isempty(NbOutputFile)
     
    233239        set(hwaitbar,'Position',BarPosition)
    234240    end
    235 else
     241else  %use as usual browser
    236242    sort_option='name';
    237243    if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2)
     
    281287htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name 
    282288DirName=get(htitlebox,'String');
     289CheckSubDir=~isempty(regexp(list{index},'^\+'));
    283290SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir
    284291ind_dot=regexp(SelectName,'\s*\.\.\.');%remove what is beyond  '...'
     
    289296    FullSelectName=fileparts(DirName);
    290297else
    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
     303end
     304if CheckSubDir%exist(FullSelectName,'dir')% a directory has been selected
    294305    set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action
    295306    drawnow
     
    315326function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option,filter_ext)
    316327%-------------------------------------------------------------------------
    317 ListStruct=dir(DirName);% get structure of the current directory
     328ListStruct=dir_uvmat(DirName);% get structure of the current directory
    318329NumFiles=0; %default
    319330if 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 %     else
    323331    ListFiles={};
    324332    return
    325 %     end
    326333end
    327334ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
    328335ListFiles=ListCells(1,:);%list of file names
    329336check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     337% for ilist=1:numel(check_dir)
     338%     if check_dir(ilist)
    330339ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
     340%     end
     341% end
    331342if exist('filter_ext','var') && ~strcmp(filter_ext,'*') &&~strcmp(filter_ext,'uigetdir')
    332343    if strcmp(filter_ext,'image')
Note: See TracChangeset for help on using the changeset viewer.