Actual source code: rpath.c
1: /*$Id: rpath.c,v 1.31 2001/03/23 23:20:30 balay Exp $*/
3: #include petsc.h
4: #include petscsys.h
5: #if defined(PETSC_HAVE_PWD_H)
6: #include <pwd.h>
7: #endif
8: #include <ctype.h>
9: #include <sys/types.h>
10: #include <sys/stat.h>
11: #if defined(PETSC_HAVE_UNISTD_H)
12: #include <unistd.h>
13: #endif
14: #if defined(PETSC_HAVE_STDLIB_H)
15: #include <stdlib.h>
16: #endif
17: #if !defined(PARCH_win32)
18: #include <sys/utsname.h>
19: #endif
20: #if defined(PARCH_win32)
21: #include <windows.h>
22: #include <io.h>
23: #include <direct.h>
24: #endif
25: #if defined (PARCH_win32_gnu)
26: #include <windows.h>
27: #endif
28: #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H)
29: #include <sys/systeminfo.h>
30: #endif
31: #include "petscfix.h"
33: /*@C
34: PetscGetRelativePath - Given a filename, returns the relative path (removes
35: all directory specifiers).
37: Not Collective
39: Input parameters:
40: + fullpath - full pathname
41: . path - pointer to buffer to hold relative pathname
42: - flen - size of path
44: Level: developer
46: Concepts: relative path
47: Concepts: path^relative
49: .seealso: PetscGetFullPath()
50: @*/
51: int PetscGetRelativePath(const char fullpath[],char path[],int flen)
52: {
53: char *p;
54: int ierr;
57: /* Find string after last / or entire string if no / */
58: PetscStrrchr(fullpath,'/',&p);
59: PetscStrncpy(path,p,flen);
60: return(0);
61: }