xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Directory()

Loads file and directory information into a two-dimensional array.

Syntax

Directory( <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 available 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 Directory()
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>. If no matching file is found, or if an error occurs, the return value is an empty array.

Description

The Directory() function is used to collect file and/or directory information in a two dimensional array of five columns. Each column can be accessed using #define constants from the DIRECTRY.CH file.

Constants for the Directory() 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(), DirectoryRecurse(), DirRemove(), File(), FileStats(), IsDirectory(), MakeDir()
Category: Directory functions , File functions
Header:Directry.ch
Source:rtl\direct.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example first retrieves information about a group of files and
// then the volume information of the C: drive

   #include "Directry.ch"

   PROCEDURE Main
      LOCAL aDir

      aDir := Directory( "*.prg" )

      AEval( aDir, {|a| QOut( a[F_NAME] ) } )

      aDir := Directory( "C:", "V" )

      AEval( aDir[1], {|x| QOut( x ) } )

   RETURN

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