ADIR() | Fill a series of arrays with directory information |
CURDIR() | Return the current DOS directory |
DIRCHANGE() | Change the current DOS directory |
DIRMAKE() | Create a directory |
DIRREMOVE() | Remove a directory |
DISKCHANGE() | Change the current DOS disk drive |
DISKNAME() | Return the current DOS drive |
DISKSPACE() | Return the space available on a specified disk |
DOSPATH() | Returns file name as DOS file name. |
MAKEPATH() | Returns path to file in UNIX style. |
STARTPATH() | Returns full path and name of program. |
ADIR([<cFilespec>],[<aFilenames>],[<aSizes>],[<aDates>], [<aTimes>],[<aAttributes>]) --> nFiles
<cFilespec> | is the path specification of files to include in the |
scan of the DEFAULT directory. It is a standard file specification that | |
can include the wildcard characters * and ?, as well as a drive and path | |
reference. If omitted, the default specification is *.*. | |
<aFilenames> | is the array to fill with the file names matching |
<cFilespec> | . Each element contains the file name and extension as a |
character string in all uppercase letters. | |
<aSizes> | is the array to fill with the sizes of the corresponding |
files in the <aFilenames> array. Each element is a numeric data type. | |
<aDates> | is the array to fill with the dates of the corresponding |
files in the <aFilenames> array. Each element is a date data type. | |
<aTimes> | is the array to fill with the times of the corresponding |
files in the <aFilenames> array. Each element filled contains a | |
character string of the form: hh:mm:ss. | |
<aAttributes> | is the array to fill with attributes of the |
corresponding files in the <aFilenames> array. Each element is a | |
character string. If <aAttributes> is specified, hidden, system, and | |
directory files are included as well as normal files. If <aAttributes> | |
is not specified, only normal files are included. |
ADIR() returns the number of files matching the directory skeleton described in <cFilespec>.
ADIR() is an array function that performs two basic operations. First, it returns the number of files matching the file specification. Second, it fills a series of arrays with file names, sizes, dates, times, and attributes.
ADIR() is a compatibility function and therefore not recommended. It is superseded by the DIRECTORY() function which returns all file information in a multidimensional array.
This example creates an array to hold the names of all .txt files in the current DEFAULT directory, then uses AEVAL() to list them to the console: LOCAL aFiles[ADIR("*.TXT")] ADIR("*.TXT", aFiles) AEVAL(aFiles, { |element| QOUT(element) })
CURDIR([<cDrivespec>]) --> cDirectory
CURDIR() returns the current DOS directory of the drive specified by <cDrivespec> as a character string without either leading or trailing backslash (\) characters.
If an error occurs, or the current directory of the specified drive is the root directory, CURDIR() returns a null string ("").
CURDIR() is an environment function that gives you the name of the current DOS directory, ignoring the SET DEFAULT and SET PATH settings.
These examples illustrate various CURDIR() results: ? CURDIR("E:") // Result: null string--root directory ? CURDIR("C") // Result: dir1\dir2 ? CURDIR("C:") // Result: dir1\dir2 ? CURDIR() // Result: null string--root directory ? CURDIR("A") // Result: null string--drive not ready
DIRCHANGE(<cDir>) --> nSuccess
DIRCHANGE() returns 0 if successful; -1 if there is an argument error. Otherwise, DIRCHANGE() returns the DOS error code.
DIRCHANGE() changes the current DOS directory. This function may also be used to determine whether or not a directory exists.
The following example attempts to change to the "c:\dos" directory. If it is unsuccessful, an error message is displayed. nResult := DIRCHANGE("c:\dos") IF nResult != 0 ? "Cannot change directory. " DO CASE CASE nResult == 3 ?? "Directory does not exist." CASE nResult == 5 ?? "Access to directory denied." END BREAK ENDIF You may also use something like this: DIRCHANGE( "..\..\test" )
DIRMAKE(<cNewDir>) --> nSuccess
DIRMAKE() returns 0 if successful; -1 if there is an argument error. Otherwise, DIRMAKE() returns the DOS error code.
DIRMAKE() creates a specified directory. Note that first you must have sufficient rights to create a directory. To create nested subdirectories, you must create each subdirectory separately, starting from the top-level directory that you want to create (see example below.)
This example assumes that C:\TEST exists and uses DIRMAKE() twice to create a nested subdirectory under it: DIRMAKE("c:\test\one") // Create top-most one nResult := DIRMAKE("c:\test\one\two") IF nResult != 0 ? "Cannot make directory, DOS error ", nResult BREAK ENDIF You may also use something like this: DIRMAKE( ".\test" )
DIRREMOVE(<cDirName>) --> nSuccess
DIRREMOVE() returns 0 if successful; -1 if there is an argument error. Otherwise, DIRREMOVE returns the DOS error code.
DIRREMOVE() removes a specified directory. Note that you must first have sufficient rights to delete a directory. A directory must be empty in order to be deleted. Therefore, to delete a directory that contains subdirectories, you must first delete the subdirectories (see example below).
This example uses DIRREMOVE() to delete a subdirectory named C:\TEST\ONE, which only contains an empty subdirectory named C:\TEST\ONE\TWO: DIRREMOVE("c:\test\one\two") // First delete lowest dir nResult := DIRREMOVE("c:\test\one") // Then delete higher dir IF nResult != 0 ? "Cannot remove directory, DOS error ", siResult BREAK ENDIF
DISKCHANGE(<cDrive>) --> lSuccess
DISKCHANGE() returns true (.T.) if successful; otherwise, it returns false (.F.).
This example uses DISKCHANGE() to change to drive "D": IF DISKCHANGE("D:") ? "Successfully changed" ELSE ? "Not changed" ENDIF This example builds a string that contains all currently available drives on your system: FUNCTION AllDrives() LOCAL wI, cDrives := "" FOR wI := 1 TO 26 IF DISKCHANGE( Chr(wI + 64) ) cDrives := cDrives + Chr(wI + 64) ENDIF NEXT RETURN cDrives
DISKNAME() --> cDrive
No arguments
DISKNAME() returns the letter of the current DOS drive, without a trailing colon.
This example illustrates the relationship between DISKNAME()and DISKCHANGE() and shows that DISKNAME() is unaffected by the SET DEFAULT TO command: ? DISKNAME() // C SET DEFAULT TO A ? DISKNAME() // C DISKCHANGE("A") ? DISKNAME() // A DISKCHANGE("C") ? DISKNAME() // C
DISKSPACE([<nDrive>]) --> nBytes
DISKSPACE() returns the number of bytes of empty space on the specified disk drive as an integer numeric value.
DISKSPACE() is an environment function that determines the number of available bytes remaining on the specified disk drive. It is useful when COPYing or SORTing to another drive to determine if there is enough space available before initiating the operation. You may also use DISKSPACE() with RECSIZE() and RECCOUNT() to create a procedure to back up database files.
DISKSPACE() ignores the SET DEFAULT drive setting.
This example is a user-defined function that demonstrates the use of DISKSPACE() to back up a database file to another drive: FUNCTION BackUp( cTargetFile, cTargetDrive ) LOCAL nSpaceNeeded, nTargetDrive // nSpaceNeeded := INT((RECSIZE() * ; LASTREC()) + HEADER() + 1) nTargetDrive := ASC(UPPER(cTargetDrive)) - 64 // IF DISKSPACE(nTargetDrive) < nSpaceNeeded RETURN .F. ENDIF COPY TO (cTargetDrive + ":" + cTargetFile) // RETURN .T.
DOSPATH(<sUnixFileName>) --> <sDosFileName>
Returns file name in DOS style.
DOSPATH() uses specified in CLIP function SET("C", ...) values and returns UNIX file name as DOS file name.
SET("C:", "/usr/home/user1") sUnixFileName := "/usr/home/user1/test.prg" ? DOSPATH(sUnixFileName) // --> C:\test.prg
MAKEPATH(<sDosPath>) --> <sUnixPath>
Returns string <sUnixPath>, what equal the DOS-style path to file <sDosPath>
MAKEPATH() converts string with path to file in DOS-style <sDosPath> to string with path in UNIX-style <sUnixPath>
SET("C:\", "/usr/home/user1/") sFileName := "C:\clip\include\clip.ch" ? MAKEPATH(sFileName) // --> /usr/home/user1/clip/include/clip.ch
STARTPATH() --> <sPath>
No arguments
Returns the string <sPath> what contain full path and name of started program.
STARTPATH() returns the string <sPath> what contain full path and name of started program.
? CURDIR() // --> /usr/home/user1/test ? STARTPATH() // --> /usr/home/user1/test/mytest ? DIRCHANGE("mybase") // --> 0 ? CURDIR() // --> /usr/home/user1/test/mybase ? STARTPATH() // --> /usr/home/user1/test/mytest
No dependies of platform.