Doxygen Source Code Documentation
zglobb.m
Go to the documentation of this file.00001 function [err,ErrMessage, NameList] = zglobb (Identifiers, Opt)
00002 %
00003 % [err, ErrMessage, List] = zglobb (Identifiers, [Opt])
00004 %
00005 %Purpose:
00006 % returns the list of files specified in Identifiers
00007 %
00008 %
00009 %Input Parameters:
00010 % Identifiers is a cellstr identifying which briks to use
00011 % Identifiers = {'ADzst2r*ir.alnd2AAzs+orig.HEAD' , 'AFzst2r*ir.alnd2AAzs+orig.HEAD'}
00012 % Opt is an optional Options structure
00013 % .LsType : type of output List
00014 % 'l' --> (default) Create a Nx1 structure vector with fields identical to those returned by dir
00015 % '|' --> Create a | delimited string with al the filenames in it
00016 % .NoExt : (default is '') a string containing a | delimited list of filename extensions to remove
00017 % example '.HEAD|.BRIK'
00018 %
00019 %Output Parameters:
00020 % err : 0 No Problem
00021 % : 1 Mucho Problems
00022 % ErrMessage : Any error or warning messages
00023 % List is the list of files with a format depending on Opt.LsType
00024 %
00025 %Key Terms:
00026 %
00027 %More Info :
00028 % ? as a wildcard is not woring
00029 %
00030 %
00031 %
00032 % Author : Ziad Saad
00033 % Date : Fri Feb 09 09:55:01 EST 2001
00034 % LBC/NIMH/ National Institutes of Health, Bethesda Maryland
00035
00036
00037 %Define the function name for easy referencing
00038 FuncName = 'zglobb';
00039
00040 %Debug Flag
00041 DBG = 1;
00042
00043 %initailize return variables
00044 err = 1;
00045 ErrMessage = 'Undetermined';
00046 NameList = [];
00047
00048 if (nargin == 1),
00049 Opt.LsType = 'l';
00050 Opt.NoExt = '';
00051 else
00052 if (~isfield (Opt, 'LsType') | isempty(Opt.LsType)), Opt.LsType = 'l'; end
00053 if (~isfield (Opt, 'NoExt') | isempty(Opt.NoExt)), Opt.NoExt = ''; end
00054 end
00055
00056
00057 switch Opt.LsType,
00058 case 'l',
00059 NameList = [];
00060 case '|',
00061 NameList = '';
00062 otherwise,
00063 ErrMessage = sprintf('%s is an unknown Opt.LsType value', Opt.LsType);
00064 err = 1;
00065 return;
00066 end
00067
00068 %get the names of the BRIKS identified in Identifiers
00069 N_ID = length(Identifiers);
00070
00071 cnt = 0;
00072 for (i=1:1:N_ID)
00073 sd = dir (char(Identifiers(i)));
00074 ns = length(sd);
00075 for (j=1:1:ns)
00076 if (~strcmp(sd(j).name, '.') & ~strcmp(sd(j).name, '..'))
00077 cnt = cnt + 1;
00078 if (~isempty(Opt.NoExt)),
00079 sd(j).name = RemoveExtension (sd(j).name, Opt.NoExt);
00080 end
00081 switch Opt.LsType,
00082 case 'l',
00083 NameList(cnt).name = sd(j).name;
00084 NameList(cnt).date = sd(j).date;
00085 NameList(cnt).bytes = sd(j).bytes;
00086 NameList(cnt).isdir = sd(j).isdir;
00087 case '|'
00088 NameList = sprintf('%s|%s',NameList,sd(j).name);
00089 end
00090 end
00091 end
00092 end
00093
00094 if (Opt.LsType == '|'),
00095 NameList = NameList(2:length(NameList)); %get rid of first |
00096 end
00097
00098 if (cnt == 0),
00099 ErrMessage = 'No match';
00100 return;
00101 end
00102
00103
00104 err = 0;
00105 ErrMessage = '';
00106 return;
00107