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