Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > G

getwd(3C)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

getwd() — get pathname of current working directory

SYNOPSIS

#include <unistd.h>

char *getwd(char *buf);

DESCRIPTION

getwd() places the absolute pathname of the current working directory in the array pointed to by buf, and returns buf.

If the length of the pathname of the current working directory is greater than PATH_MAX+1 bytes, getwd() fails and returns a null pointer.

RETURN VALUE

Upon successful completion, getwd() returns a pointer to the current directory pathname. Otherwise, it returns NULL with errno set.

ERRORS

getwd() fails if the following condition is encountered:

ENAMETOOLONG

The length of the specified path name exceeds PATH_MAX+1 bytes, or the length of a component of the path name exceeds NAME_MAX bytes while _POSIX_NO_TRUNC is in effect.

getwd() may fail if any of the following conditions are encountered:

EACCES

Read or search permission is denied for a component of pathname.

EFAULT

buf points outside the allocated address space of the process. getwd() may not always detect this error.

EXAMPLES

#include <stdio.h> #include <unistd.h> char *cwd; char buf[PATH_MAX+1]; ... if ((cwd = getwd(buf)) == NULL) { perror("getwd"); exit(1); } puts(cwd);

WARNINGS

For portability, getcwd() is preferred over this function.

AUTHOR

getwd() was developed by HP and the University of California, Berkeley.

STANDARDS CONFORMANCE

getwd(): XPG4.2

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.