Actual source code: fwd.c

      1: #define PETSC_DLL
      2: /*
      3:       Code for manipulating files.
      4: */
     5:  #include petsc.h
     6:  #include petscsys.h
      7: #if defined(PETSC_HAVE_PWD_H)
      8: #include <pwd.h>
      9: #endif
     10: #include <ctype.h>
     11: #include <sys/types.h>
     12: #include <sys/stat.h>
     13: #if defined(PETSC_HAVE_UNISTD_H)
     14: #include <unistd.h>
     15: #endif
     16: #if defined(PETSC_HAVE_STDLIB_H)
     17: #include <stdlib.h>
     18: #endif
     19: #if defined(PETSC_HAVE_SYS_UTSNAME_H)
     20: #include <sys/utsname.h>
     21: #endif
     22: #if defined(PETSC_HAVE_DIRECT_H)
     23: #include <direct.h>
     24: #endif
     25: #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H)
     26: #include <sys/systeminfo.h>
     27: #endif
     28: #include "petscfix.h"

     32: /*@C
     33:    PetscGetWorkingDirectory - Gets the current working directory.

     35:    Not Collective

     37:    Input Parameters:
     38: .  len  - maximum length of path

     40:    Output Parameter:
     41: .  path - use to hold the result value. The string should be long enough
     42:           to hold the path.

     44:    Level: developer

     46:    Concepts: working directory

     48: @*/
     49: PetscErrorCode PETSC_DLLEXPORT PetscGetWorkingDirectory(char path[],size_t len)
     50: {
     51: #if defined(PETSC_HAVE_GETCWD)
     53:   getcwd(path,len);
     54:   return(0);
     55: #elif defined(PETSC_HAVE__GETCWD)
     57:   _getcwd(path,len);
     58:   return(0);
     59: #elif defined(PETSC_HAVE_GETWD)
     61:   getwd(path);
     62:   return(0);
     63: #else
     64:   SETERRQ(PETSC_ERR_SUP_SYS, "Could not find getcwd() or getwd()");
     65: #endif
     66: }