chdir()

change current working directory 

Function


SYNOPSIS

#include <unistd.h>

int chdir(const char *pathname);


DESCRIPTION

The chdir() function changes the current working directory to be pathname. The current directory is the beginning point for file searches when path names are not absolute. If the chdir() function fails, the current working directory remains unchanged.


PARAMETERS

pathname 

Is the path name of a directory.


RETURN VALUES

If successful, chdir() returns a value of zero. On failure, it returns -1 and sets errno to the one of the following:

EACCES 

Search permission is denied for a component of the path name.

EFAULT 

pathname points outside the allocated address space of the process.

EINTR 

A signal interrupted the call.

EIO 

An I/O error occurred while reading from or writing to the file system.

ENAMETOOLONG 

The pathname parameter exceeds PATH_MAX in length or a pathname component is longer than NAME_MAX while _POSIX_NO_TRUNC is in effect.

ENOENT 

The named directory does not exist or pathname is an empty string.

ENOTDIR 

A component of the pathname is not a directory.


CONFORMANCE

POSIX.1 (1996), with exceptions.


MULTITHREAD SAFETY LEVEL

Async-signal-safe.


PORTING ISSUES

Windows supports multiple root directories, one for each drive, and also maintains a current working directory on each drive. The chdir() and fchdir() functions update the current working directory for the drive specified in pathname, or for the current default drive if no drive is specified in pathname.


AVAILABILITY

MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
fchdir(), getcwd()


MKS Toolkit 9.3 Documentation Build 6.