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: #undef __FUNCT__
37: /*@C
38: PetscGetWorkingDirectory - Gets the current working directory.
40: Not Collective
42: Input Parameters:
43: . len - maximum length of path
45: Output Parameter:
46: . path - use to hold the result value. The string should be long enough
47: to hold the path.
49: Level: developer
51: Concepts: working directory
53: @*/
54: int PetscGetWorkingDirectory(char path[],int len)
55: {
56: #if defined(PETSC_HAVE_GETCWD)
58: getcwd(path,len);
59: return(0);
60: #elif defined(PETSC_HAVE__GETCWD)
62: _getcwd(path,len);
63: return(0);
64: #elif defined(PETSC_HAVE_GETWD)
66: getwd(path);
67: return(0);
68: #else
69: SETERRQ(PETSC_ERR_SUP, "Could not find getcwd() or getwd()");
70: #endif
71: }