xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DirectoryRecurse()

Loads file information recursively into a two-dimensional array.

Syntax

DirectoryRecurse( <cDirSpec>, [<cAttributes>] ) --> aDirectory

Arguments

<cDirSpec>
This is a character string holding the drive, directory and/or file specification to retrieve information for. It defaults to the string "*.*" which retrieves all avalable information from the operating system.
<cAttributes>
Optionally, a character string holding file attributes can be specified. Information about files carrying these attributes is retrieved. One or more characters of the table below can be included in <cAttributes>.

Attributes for DirectoryRecurse()
AttributeMeaning
DInclude directories
HInclude hidden files
SInclude system files
VSearch for the DOS volume label and exclude all other files

Return

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.

Description

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
ConstantPositionDescriptionData type
F_NAME1File nameCharacter
F_SIZE2File size in bytesNumeric
F_DATE3Creation dateDate
F_TIME4Creation timeCharacter
F_ATTR5File attributesCharacter

Note that <cDirSpec> can include wild card characters to specify a group of files.

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe