FULLPATHQQ

Run-Time Function: Returns the full path for a specified file or directory.

Module: USE DFLIB

Syntax

result = FULLPATHQQ (name, pathbuf)

name
(Input) Character*(*). Item for which you want the full path. Can be the name of a file in the current directory, a relative directory or filename, or a network uniform naming convention (UNC) path.


pathbuf
(Output) Character*(*). Buffer to receive full path of the item specified in name.

Results:

The result is of type INTEGER(4). The result is the length of the full path in bytes, or 0 if the function fails (usually for an invalid name).

The length of the full path depends upon how deeply the directories are nested on the drive you are using. If the full path is longer than the character buffer provided to return it (pathbuf), FULLPATHQQ returns only that portion of the path that fits into the buffer.

Check the length of the path before using the string returned in pathbuf. If the longest full path you are likely to encounter does not fit into the buffer you are using, allocate a larger character buffer. You can allocate the largest possible path buffer with the following statements:

  USE DFLIB
  CHARACTER($MAXPATH) pathbuf

$MAXPATH is a symbolic constant defined in module DFLIB.F90 (in the \DF98\INCLUDE subdirectory) as 260.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: SPLITPATHQQ

Example

     USE DFLIB
     CHARACTER($MAXPATH) buf
     CHARACTER(3)        drive
     CHARACTER(256)      dir
     CHARACTER(256)      name
     CHARACTER(256)      ext
     CHARACTER(256)      file

     INTEGER(4)          len

     DO WHILE (.TRUE.)
       WRITE (*,*)
       WRITE (*,'(A, \)') ' Enter filename (Hit &
                            RETURN to exit): '
       len = GETSTRQQ(file)
       IF (len .EQ. 0) EXIT
       len = FULLPATHQQ(file, buf)
       IF (len .GT. 0) THEN
         WRITE (*,*) buf(:len)
       ELSE
         WRITE (*,*) 'Can''t get full path'
         EXIT
       END IF
!
!      Split path
       WRITE (*,*)
       len = SPLITPATHQQ(buf, drive, dir, name, ext)
       IF (len .NE. 0) THEN
         WRITE (*, 900) ' Drive: ', drive
         WRITE (*, 900) ' Directory: ', dir(1:len)
         WRITE (*, 900) ' Name: ', name
         WRITE (*, 900) ' Extension: ', ext
       ELSE
         WRITE (*, *) 'Can''t split path'
       END IF
     END DO
900  FORMAT (A, A)
     END