GETDRIVEDIRQQ

Run-Time Function: Gets the path of the current working directory on a specified drive.

Module: USE DFLIB

Syntax

result = GETDRIVEDIRQQ (drivedir)

drivedir
(Input; output) Character*(*). On input, drive whose current working directory path is to be returned. On output, string containing the current directory on that drive in the form d:\dir.

Results:

The result is of type INTEGER(4). The result is the length (in bytes) of the full path of the directory on the specified drive. Zero is returned if the path is longer than the size of the character buffer drivedir.

You specify the drive from which to return the current working directory by putting the drive letter into drivedir before calling GETDRIVEDIRQQ. To make sure you get information about the current drive, put the symbolic constant FILE$CURDRIVE (defined in DFLIB.F90 in the \DF98\INCLUDE subdirectory) into drivedir.

Because drives are identified by a single alphabetic character, GETDRIVEDIRQQ examines only the first letter of drivedir. For instance, if drivedir contains the path c:\fps90\bin, GETDRIVEDIRQQ (drivedir) returns the current working directory on drive C and disregards the rest of the path. The drive letter can be uppercase or lowercase.

The length of the path returned depends on how deeply the directories are nested on the drive specified in drivedir. If the full path is longer than the length of drivedir, GETDRIVEDIRQQ returns only the portion of the path that fits into drivedir. If you are likely to encounter a long path, allocate a buffer of size $MAXPATH ($MAXPATH = 260).

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS DLL LIB

See Also: CHANGEDRIVEQQ, CHANGEDIRQQ, GETDRIVESIZEQQ, GETDRIVESQQ, GETLASTERRORQQ, SPLITPATHQQ

Example

!  Program to demonstrate GETDRIVEDIRQQ
USE DFLIB
CHARACTER($MAXPATH) dir
INTEGER(4) length

!  Get current directory
dir = FILE$CURDRIVE
length = GETDRIVEDIRQQ(dir)
IF (length .GT. 0) THEN
  WRITE (*,*) 'Current directory is: '
  WRITE (*,*) dir
ELSE
  WRITE (*,*) 'Failed to get current directory'
END IF
END