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.

File names are treated as multibyte sequences and are converted to Unicode (UTF-16) before passing to Win32. The conversion is either performed based on the current thread locale, set using uselocale() or the process locale as set by a call to setlocale(), and overridden by _NutConf() _NC_SET_ANSI_LOCALE and _NC_SET_UTF8_LOCALE options. Under all other conditions, the multibyte sequences are considered to be from the ANSI code page for the current windows system locale.


AVAILABILITY

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


SEE ALSO

Functions:
fchdir(), getcwd()


PTC MKS Toolkit 10.3 Documentation Build 39.