Sun Studio 12: Fortran Library Reference

1.4.17 getcwd: Get Path of Current Working Directory

The function is called by:

INTEGER*4 getcwd

status = getcwd( dirname )

dirname

character*n

Output 

The path of the current directory is returned 

Path name of the current working directory. n must be large enough for longest path name

Return value 

INTEGER*4

Output 

status=0: OK

status>0: Error code

Example: getcwd:


       INTEGER*4 getcwd, status
       character*64 dirname
       status = getcwd( dirname )
       if ( status .ne. 0 ) stop ’getcwd: error’
       write(*,*) dirname
       end

See also: chdir(3F), perror(3F), and getwd(3).

Note: the path names cannot be longer than MAXPATHLEN as defined in <sys/param.h>.