Actual source code: rpath.c
petsc-3.3-p7 2013-05-11
2: #include <petscsys.h>
3: #if defined(PETSC_HAVE_PWD_H)
4: #include <pwd.h>
5: #endif
6: #include <ctype.h>
7: #include <sys/types.h>
8: #include <sys/stat.h>
9: #if defined(PETSC_HAVE_UNISTD_H)
10: #include <unistd.h>
11: #endif
12: #if defined(PETSC_HAVE_STDLIB_H)
13: #include <stdlib.h>
14: #endif
15: #if defined(PETSC_HAVE_SYS_UTSNAME_H)
16: #include <sys/utsname.h>
17: #endif
18: #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H)
19: #include <sys/systeminfo.h>
20: #endif
24: /*@C
25: PetscGetRelativePath - Given a filename, returns the relative path (removes
26: all directory specifiers).
28: Not Collective
30: Input parameters:
31: + fullpath - full pathname
32: . path - pointer to buffer to hold relative pathname
33: - flen - size of path
35: Level: developer
37: Concepts: relative path
38: Concepts: path^relative
40: .seealso: PetscGetFullPath()
41: @*/
42: PetscErrorCode PetscGetRelativePath(const char fullpath[],char path[],size_t flen)
43: {
44: char *p;
48: /* Find string after last / or entire string if no / */
49: PetscStrrchr(fullpath,'/',&p);
50: PetscStrncpy(path,p,flen);
51: return(0);
52: }