Actual source code: fwd.c

  1: /*$Id: fwd.c,v 1.34 2001/03/23 23:20:30 balay Exp $*/
  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(PARCH_win32)
 20: #include <sys/utsname.h>
 21: #endif
 22: #if defined(PARCH_win32)
 23: #include <windows.h>
 24: #include <io.h>
 25: #include <direct.h>
 26: #endif
 27: #if defined (PARCH_win32_gnu)
 28: #include <windows.h>
 29: #endif
 30: #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H)
 31: #include <sys/systeminfo.h>
 32: #endif
 33: #include "petscfix.h"

 35: /*@C
 36:    PetscGetWorkingDirectory - Gets the current working directory.

 38:    Not Collective

 40:    Input Parameters:
 41: .  len  - maximum length of path

 43:    Output Parameter:
 44: .  path - use to hold the result value. The string should be long enough
 45:           to hold the path.

 47:    Level: developer

 49:    Concepts: working directory

 51: @*/
 52: int PetscGetWorkingDirectory(char path[],int len)
 53: {
 54: #if defined(PETSC_HAVE_GETCWD)
 56:   getcwd(path,len);
 57:   return(0);
 58: #elif defined(PETSC_HAVE__GETCWD)
 60:   _getcwd(path,len);
 61:   return(0);
 62: #elif defined(PETSC_HAVE_GETWD)
 64:   getwd(path);
 65:   return(0);
 66: #else
 67:   SETERRQ(PETSC_ERR_SUP, "Could not find getcwd() or getwd()");
 68: #endif
 69: }