xHarbour Reference Documentation > Function Reference |
Fills pre-allocated arrays with file and/or directory information.
ADir( [<cFileMask>], ; [<aName>] , ; [<aSize>] , ; [<aDate>] , ; [<aTime>] , ; [<aAttr>] ) --> nDirEnries
The function returns a numeric value indicating the number of files meeting the search condidtion defined with <cFileMask>.
ADir() searches a directory for files meeting a search pattern <cFileMask>, and optionally fills arrays with various file information. The number of files meeting the search condition is usually determined in an initial call to ADir(). The return value of the initial call is then used to pre-allocate one-dimensional arrays that are filled with the desired informationin a second call to ADir().
To include files with Hidden, Directory, or System attributes, the according attribute must be specified for the search.
Note: ADir() is a compatibility function. It is superseded by the Directory() function which returns all file information in a multi-dimensional array.
See also: | AChoice(), AEval(), AScan(), ASort(), Directory(), Len() |
Category: | Array functions , File functions |
Source: | rtl\adir.prg |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// This example demonstrates the two-step approach for obtaining file // information about .LOG files. The initial call determines the number // of files found. This result is used to pre-allocate arrays to fill // in a second call to ADir(). PROCEDURE MAIN() LOCAL aName, aSize, aDate, aTime, aAttr LOCAL nLen, i nLen := ADir( "*.log" ) IF nLen > 0 aName := Array( nLen ) aSize := Array( nLen ) aDate := Array( nLen ) aTime := Array( nLen ) aAttr := Array( nLen ) ADir( "*.log", aName, aSize, aDate, aTime, aAttr ) FOR i := 1 TO nLen ? aName[i], aSize[i], aDate[i], aTime[i], aAttr[i] NEXT ELSE ? "This directory does not contain .log files." ENDIF RETURN
http://www.xHarbour.com