Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public
Document Table of Contents

GETDRIVEDIRQQ

Portability Function: Returns the path of the current working directory on a specified drive.

Module

USE IFPORT

result = GETDRIVEDIRQQ (drivedir)

drivedir

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

Results

The result type is 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 IFPORT.F90) 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).

On Linux* systems, the function gets a path only when symbolic constant FILE$CURDRIVE has been applied to drivedir.

Example

!  Program to demonstrate GETDRIVEDIRQQ
USE IFPORT
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