#include #if defined(PETSC_HAVE_PWD_H) #include #endif #include #include #if defined(PETSC_HAVE_UNISTD_H) #include #endif #if defined(PETSC_HAVE_SYS_UTSNAME_H) #include #endif #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H) #include #endif /*@C PetscGetRelativePath - Given a filename, returns the relative path (removes all directory specifiers). Not Collective Input parameters: + fullpath - full pathname . path - pointer to buffer to hold relative pathname - flen - size of path Level: developer Concepts: relative path Concepts: path^relative .seealso: PetscGetFullPath() @*/ PetscErrorCode PetscGetRelativePath(const char fullpath[],char path[],size_t flen) { char *p; PetscErrorCode ierr; PetscFunctionBegin; /* Find string after last / or entire string if no / */ ierr = PetscStrrchr(fullpath,'/',&p);CHKERRQ(ierr); ierr = PetscStrncpy(path,p,flen);CHKERRQ(ierr); PetscFunctionReturn(0); }