xHarbour Reference Documentation > Function Reference |
Loads file information recursively into a two-dimensional array.
DirectoryRecurse( <cDirSpec>, [<cAttributes>] ) --> aDirectory
Attributes for DirectoryRecurse()
Attribute | Meaning |
---|---|
D | Include directories |
H | Include hidden files |
S | Include system files |
V | Search for the DOS volume label and exclude all other files |
The function returns a two-dimensional array holding information about files that match <cDirSpec> in the current directory and its sub-directories. If no matching file is found, or if an error occurs, the return value is an empty array.
The DirectoryRecurse() function is used in the same way as the Directory(). The only difference is that DirectoryRecurse() scans all sub-directories in addition to the directory specified with <cDirSpec>. The result is a two dimensional array of five columns. Each column can be accessed using #define constants from the DIRECTRY.CH file.
Constants for the DirectoryRecurse() array
Constant | Position | Description | Data type |
---|---|---|---|
F_NAME | 1 | File name | Character |
F_SIZE | 2 | File size in bytes | Numeric |
F_DATE | 3 | Creation date | Date |
F_TIME | 4 | Creation time | Character |
F_ATTR | 5 | File attributes | Character |
Note that <cDirSpec> can include wild card characters to specify a group of files.
See also: | ADir(), AEval(), CurDir(), DirChange(), Directory(), DirRemove(), File(), FileStats(), IsDirectory(), MakeDir() |
Category: | Directory functions , File functions , xHarbour extensions |
Header: | Directry.ch |
Source: | rtl\direct.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example collects file in formation about PRG files in the // current directory and its sub-directories, and writes the result // to a file. PROCEDURE Main LOCAL aFiles SET ALTERNATE TO PrgFiles.txt SET ALTERNATE ON aFiles := DirectoryRecurse( "*.prg" ) AEval( aFiles, {|a| QOut( ValToPrg( a ) ) } ) SET ALTERNATE OFF SET ALTERNATE TO RETURN
http://www.xHarbour.com