Actual source code: fwd.c
1: #define PETSC_DLL
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: {
49: #if defined(PETSC_HAVE_GETCWD)
51: getcwd(path,len);
52: return(0);
53: #elif defined(PETSC_HAVE__GETCWD)
55: _getcwd(path,len);
56: return(0);
57: #elif defined(PETSC_HAVE_GETWD)
59: getwd(path);
60: return(0);
61: #else
62: SETERRQ(PETSC_ERR_SUP_SYS, "Could not find getcwd() or getwd()");
63: #endif
64: }