A file access module that gets a listing of files with a given file extension in a directory.
module GetFilesCore <src_file="getfiles.cxx"> { string+IPort2 dir<export=2>; string+IPort2 ext<export=2>; cxxmethod+req update ( .dir+req+read+notify, .ext+req+read+notify, .nFiles+write, .files+write ); int nFiles; string+OPort2 files<export=2>[.nFiles]; };
The GetFilesCore module generates file listings by scanning a directory and searching for a specified file extension. It outputs an array of strings containing the names of the files found. The file extension is specified as being the part of the filename after the final '.' character. The file extension input should not contain a preceding '.' character. It can contain a search specification (i.e. 'c*'.
The GetFilesCore module is intended to be the basis for a variety of file selection and I/O macros. It particular it is intended to be used in situations when the standard File Dialog box is not suitable. The MultiFileShell and Multiple_File_Select user macros provide examples of how this can be done.
dir
String input that specifies which directory should be searched for files. AVS/Express environment variables(e.g. $XP_PATH<1>) can be used in this directory string.
ext
String input that specifies which file extension should be searched for. This string should not contain a preceding '.' character. The file extension can contain a search specification. Therefore if the file extension is set to 'h*' all files that have extensions that begin with 'h' are listed.
nFiles
Integer output specifying the number of files that match the specified criteria.
files[nFiles]
Array of strings that contains the names of all the files that match the specified criteria.
The low-level GetFiles2Core module is used in the user macro MultiFileShell. This user macro is used in the Multiple_File_Select user macro.
Two example applications are provided. The GetFilesEg1 application gets all the files in the current project directory and allows the user to select one or more of these files. This application could be used as the basis for a full file access application. The GetFilesEg2 application gets a list of all the geometry files in the express/data/geom directory and allows the user to select one of these files. This geometry file is then read and displayed.
iac_proj/getfiles/getfmods.v contains the V definitions of the GetFilesCore module.
The low-level GetFilesMods library containing the module GetFilesCore does not specify a process. By default the express process will be used.
Jeremy Maccelari, Visual Numerics Andrew Dodd, International AVS Centre
International AVS Centre Manchester Visualization Centre Manchester Computing University of Manchester Oxford Road Manchester United Kingdom M13 9PL