chdir -- Change Directory


SYNOPSIS
#include <unistd.h>
int chdir(const char *pathname);
DESCRIPTION
chdir
changes the working directory to pathname
.
The pathname
function must specify the name of a file in the OpenEdition
HFS. See File Naming Conventions for
information on specifying OpenEdition file names.
RETURN VALUE
chdir
returns 0 if it is successful and - 1 if it is not
successful.
IMPLEMENTATION
When you call chdir
in an application compiled without the
posix
option, the directory name will be interpreted according to
the normal rules for interpretation of filenames. The directory name
should include a style prefix if the default style is not "hfs"
.
EXAMPLE
/* This example must be compiled with POSIX to run successfully. */
#include <stdio.h>
#include <unistd.h>
char wrkdir[FILENAME_MAX];
main()
{
/* Change the working directory to /bin. */
if (chdir("/bin") != 0)
perror("chdir() to /bin failed");
else {
/* Determine the current working directory. */
if (getcwd(wrkdir,sizeof(wrkdir)) == NULL)
perror("getcwd() error");
else
printf("Current working directory is: %sn",wrkdir);
}
}
RELATED FUNCTIONS
getcwd
SEE ALSO