Actual source code: fwd.c
petsc-3.7.1 2016-05-15
Report Typos and Errors

      2: /*
      3:       Code for manipulating files.
      4: */
      5: #include <petscsys.h>
      6: #if defined(PETSC_HAVE_PWD_H)
      7: #include <pwd.h>
      8: #endif
      9: #include <ctype.h>
     10: #include <sys/stat.h>
     11: #if defined(PETSC_HAVE_UNISTD_H)
     12: #include <unistd.h>
     13: #endif
     14: #if defined(PETSC_HAVE_SYS_UTSNAME_H)
     15: #include <sys/utsname.h>
     16: #endif
     17: #if defined(PETSC_HAVE_DIRECT_H)
     18: #include <direct.h>
     19: #endif
     20: #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H)
     21: #include <sys/systeminfo.h>
     22: #endif

     26: /*@C
     27:    PetscGetWorkingDirectory - Gets the current working directory.

     29:    Not Collective

     31:    Input Parameters:
     32: .  len  - maximum length of path

     34:    Output Parameter:
     35: .  path - use to hold the result value. The string should be long enough
     36:           to hold the path.

     38:    Level: developer

     40:    Concepts: working directory

     42: @*/
     43: PetscErrorCode  PetscGetWorkingDirectory(char path[],size_t len)
     44: {
     46: #if defined(PETSC_HAVE_GETCWD)
     47:   if (!getcwd(path,len)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"getcwd()");
     48: #elif defined(PETSC_HAVE__GETCWD)
     49:   _getcwd(path,len);
     50: #elif defined(PETSC_HAVE_GETWD)
     51:   getwd(path);
     52: #else
     53:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP_SYS, "Could not find getcwd() or getwd()");
     54: #endif
     55:   return(0);
     56: }