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