Changing the current working directoryΒΆ

chdir()

Change the current working directory


SYNTAX

chdir(pathname)

The chdir() function allows the current working directory to be changed within a Sculptor program. The new working directory is specified in pathname, which may be a string constant or a string expression.

The function returns 0 if the directory change was successful, and returns an error code otherwise. The possible return values for chdir(), which are defined in $SCULPTOR/include/errors.h, are:

OKAY (0)

No error encountered

NOFILE (1)

The directory specified in pathname could not be found

NOPERMS (2)

Access permission to read the named directory denied


NOTES

  • The directory change remains valid until another chdir is successfully performed, or until the program terminates.

  • On DOS systems, the new directory remains valid even when the current program exits.


EXAMPLE

!temp RetVal,,u1

     RetVal = chdir("/live/data")
     switch (RetVal) {
          case = 0:
               info "Changed directory"
               break
          case = 1:
               error "Unable to change directory - directory not found"
               break
          case = 2:
               error "Unable to change directory - no read access permission"
               break
     }

RELATED TOPICS

File and directory handling functions