getcwd man page on IRIX

Man page or keyword search:  
man Server   31559 pages
apropos Keyword Search (all sections)
Output format
IRIX logo
[printable version]



getcwd(3C)							    getcwd(3C)

NAME
     getcwd - get pathname of current working directory

SYNOPSIS
     #include <unistd.h>

     char *getcwd (char *buf, size_t size);

DESCRIPTION
     getcwd returns a pointer to the current directory pathname.  The value of
     size must be at least one greater than the length of the pathname to be
     returned.

     If buf is not NULL, the pathname will be stored in the space pointed to
     by buf.

     If buf is a NULL pointer, getcwd will obtain size bytes of space using
     malloc(3C).  In this case, a subsequent call to free should be made using
     the pointer returned by getcwd as the argument. If size is less than
     zero, then getcwd will obtain an appropriate amount of space.  Passing a
     negative size and a non-NULL buf argument will lead to undefined results.

     getcwd will fail if one or more of the following are true:

     EACCES	 A parent directory cannot be read to get its name.

     EINVAL	 size is equal to 0.

     ERANGE	 size is less than the length of the pathname plus 1.

EXAMPLE
     Here is a program that prints the current working directory.

	  #include <unistd.h>
	  #include <stdio.h>

	  main()
	  {
	       char *cwd;
	       if ((cwd = getcwd(NULL, 64)) == NULL)
	       {
		    perror("pwd");
		    exit(2);
	       }
	       (void)printf("%s\n", cwd);
	       free(cwd);
	       return(0);
	  }

									Page 1

getcwd(3C)							    getcwd(3C)

SEE ALSO
     malloc(3C).

DIAGNOSTICS
     Returns NULL with errno set if size is not large enough, or if an error
     occurs in a lower-level function.

NOTES
     getcwd uses the end part of the buffer ( buf + size - 1) as temporary
     space.  Be sure that the size argument accurately reflects the space
     allocated to the buffer.

									Page 2

[top]

List of man pages available for IRIX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net