Back to index

glibc  2.9
Functions
getdirname.c File Reference
#include <unistd.h>
#include <include/sys/stat.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

char * get_current_dir_name (void)

Function Documentation

char* get_current_dir_name ( void  )

Definition at line 29 of file getdirname.c.

{
  char *pwd;
  struct stat64 dotstat, pwdstat;

  pwd = getenv ("PWD");
  if (pwd != NULL
      && stat64 (".", &dotstat) == 0
      && stat64 (pwd, &pwdstat) == 0
      && pwdstat.st_dev == dotstat.st_dev
      && pwdstat.st_ino == dotstat.st_ino)
    /* The PWD value is correct.  Use it.  */
    return __strdup (pwd);

  return __getcwd ((char *) NULL, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function: