1 #define PETSC_DLL 2 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(PETSC_HAVE_SYS_UTSNAME_H) 18 #include <sys/utsname.h> 19 #endif 20 #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H) 21 #include <sys/systeminfo.h> 22 #endif 23 #include "petscfix.h" 24 25 #undef __FUNCT__ 26 #define __FUNCT__ "PetscGetRelativePath" 27 /*@C 28 PetscGetRelativePath - Given a filename, returns the relative path (removes 29 all directory specifiers). 30 31 Not Collective 32 33 Input parameters: 34 + fullpath - full pathname 35 . path - pointer to buffer to hold relative pathname 36 - flen - size of path 37 38 Level: developer 39 40 Concepts: relative path 41 Concepts: path^relative 42 43 .seealso: PetscGetFullPath() 44 @*/ 45 PetscErrorCode PETSC_DLLEXPORT PetscGetRelativePath(const char fullpath[],char path[],size_t flen) 46 { 47 char *p; 48 PetscErrorCode ierr; 49 50 PetscFunctionBegin; 51 /* Find string after last / or entire string if no / */ 52 ierr = PetscStrrchr(fullpath,'/',&p);CHKERRQ(ierr); 53 ierr = PetscStrncpy(path,p,flen);CHKERRQ(ierr); 54 PetscFunctionReturn(0); 55 } 56