Actual source code: fwd.c
petsc-3.3-p7 2013-05-11
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/types.h>
11: #include <sys/stat.h>
12: #if defined(PETSC_HAVE_UNISTD_H)
13: #include <unistd.h>
14: #endif
15: #if defined(PETSC_HAVE_STDLIB_H)
16: #include <stdlib.h>
17: #endif
18: #if defined(PETSC_HAVE_SYS_UTSNAME_H)
19: #include <sys/utsname.h>
20: #endif
21: #if defined(PETSC_HAVE_DIRECT_H)
22: #include <direct.h>
23: #endif
24: #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H)
25: #include <sys/systeminfo.h>
26: #endif
30: /*@C
31: PetscGetWorkingDirectory - Gets the current working directory.
33: Not Collective
35: Input Parameters:
36: . len - maximum length of path
38: Output Parameter:
39: . path - use to hold the result value. The string should be long enough
40: to hold the path.
42: Level: developer
44: Concepts: working directory
46: @*/
47: PetscErrorCode PetscGetWorkingDirectory(char path[],size_t len)
48: {
50: #if defined(PETSC_HAVE_GETCWD)
51: if (!getcwd(path,len)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"getcwd()");
52: #elif defined(PETSC_HAVE__GETCWD)
53: _getcwd(path,len);
54: #elif defined(PETSC_HAVE_GETWD)
55: getwd(path);
56: #else
57: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP_SYS, "Could not find getcwd() or getwd()");
58: #endif
59: return(0);
60: }