% Load MODIS HDF file
% function for the MODIS GUI
% Copyright by Jasmine S Nahorniak, Oregon State University.
% Feb 24 2000

function GUIsublistfiles

% get the path
pathh=findobj('Tag','EditText4');
path=get(pathh,'String');
if path(end)~='/',
   path(end+1)='/';
end

% get the selected file 
filelisth=findobj('Tag','Listbox2');
filelist=get(filelisth,'String');
fileselect=get(filelisth,'Value');  % selected file
filecell=filelist(fileselect,:);
classfile=class(filecell);
if classfile(1:4)=='char'
  newfile=filecell;
else
  newfile=cat(1,filecell{:});   % convert cell to string
end

% determine if is a directory
direc=dir([path newfile]);
dircell=struct2cell(direc);
isdirec=cat(1,dircell{4});

% if is a directory
if isdirec==1,
   set(pathh,'String',[path newfile]);
   GUIlistfiles;
else   % turn load file button back on
  set(findobj('Tag','Pushbutton1'),'Enable','on');
  % set file type based on filename
  if newfile(3)~='D',  % is a level 3 mapped file
     if (newfile(5)=='M' | newfile(5)=='N' | newfile(5)=='S'),
        set(findobj('Tag','PopupMenu2'),'Value',1);
     elseif (newfile(5)=='Q')
        set(findobj('Tag','PopupMenu2'),'Value',3);
     else
        set(findobj('Tag','PopupMenu2'),'Value',2);
     end
  elseif (newfile(1:5)=='MODOC' | newfile(1:5)=='MOD28' | newfile(1:5)=='MOD03'), % is a level 2 or 1 file
     set(findobj('Tag','PopupMenu2'),'Value',4);     
  end
end
