Name

wchdir - change working directory

Library

libc.lib

Synopsis

  #include <wchar.h>
  int wchdir (const wchar_t *path);


Return values

Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Detailed description

The path argument points to the pathname of a directory which is a wide character string. The wchdir system call causes the named directory to become the current working directory, that is, the starting point for path searches of pathnames not beginning with a slash, /.


Examples

#include<wchar.h>                       /* wmkdir, wrmdir */
#include <sys/stat.h>                   /* S_IRWXU */
#include <stdio.h>                      /* printf */
int main()
{
        int ret_wmkdir = wmkdir(L"dirName", S_IRWXU);                   /* create directory */
        if(ret_wmkdir < 0)
                {
                printf("error creating directory");
                return -1;
                }
        else
                {
                int ret_wchdir = wchdir(L"dirName");                    /* change directory */
                if(ret_wchdir < 0)
                        {
                        printf("error changing directory");
                        return -1;
                        }
                else
                        {
                        printf("working directory changed");
                        }
                        wrmdir(L"dirname");                             /* remove directory */                  
                }
        return 0;                       
}

         

Output

working directory changed

         

Errors

The wchdir system call will fail and the current working directory will be unchanged if one or more of the following are true:
[ENOTDIR]
  Not a directory.
[ENAMETOOLONG]
  A component of a pathname exceeded 255 characters.
[ENOENT]
  The named file does not exist.
[EINVAL]
  Invalid argument.

See also

chdir

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top