summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/stella/getfnames.m
blob: 4990451731d12747f2c2b6952420e2304261d1ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
% function [fn,dn] = getfnames(direc,opt) 
% Input:
%    direc = directory
%    opt = wildcat
% Output:
%    fn = a cell with all filenames under direc and with opt
%    dn = a cell with all directory names under direc and with opt
% For example, getfnames('19990910','*.jpg');
% Set IS_PC according to your platform in globalenvar.m

% Stella X. Yu, 2000.

function [fn,dn] = getfnames(direc,opt)

if (nargin<1 | isempty(direc)),
    direc = '.';
end

if nargin<2 | isempty(opt),
    opt = [];
end 

fn = {};
dn = {};

cur_dir = pwd;
cd(direc);
s = dir(opt);
if isempty(s),
   disp('getfnames: no data');
   return;
end
 
n = length(s);
i = 1; 
j = 1; 
for k=1:n,
   if s(k).isdir,
      dn{j,1} = s(k).name;
      j = j + 1;
   else
      fn{i,1} = s(k).name;
      i = i + 1;
   end
end
      cd(cur_dir)
%[fn{1:n,1}]=deal(s.name);