Actual source code: fwd.c
1: /*
2: Code for manipulating files.
3: */
4: #include petsc.h
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
27: #include "petscfix.h"
31: /*@C
32: PetscGetWorkingDirectory - Gets the current working directory.
34: Not Collective
36: Input Parameters:
37: . len - maximum length of path
39: Output Parameter:
40: . path - use to hold the result value. The string should be long enough
41: to hold the path.
43: Level: developer
45: Concepts: working directory
47: @*/
48: PetscErrorCode PetscGetWorkingDirectory(char path[],size_t len)
49: {
50: #if defined(PETSC_HAVE_GETCWD)
52: getcwd(path,len);
53: return(0);
54: #elif defined(PETSC_HAVE__GETCWD)
56: _getcwd(path,len);
57: return(0);
58: #elif defined(PETSC_HAVE_GETWD)
60: getwd(path);
61: return(0);
62: #else
63: SETERRQ(PETSC_ERR_SUP_SYS, "Could not find getcwd() or getwd()");
64: #endif
65: }