#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; No Fortran Support Input Parameters: + fullpath - full pathname - flen - size of `path` Output Parameter: . path - buffer that holds relative pathname Level: developer .seealso: `PetscGetFullPath()` @*/ PetscErrorCode PetscGetRelativePath(const char fullpath[], char path[], size_t flen) { char *p = NULL; PetscFunctionBegin; /* Find string after last / or entire string if no / */ PetscCall(PetscStrrchr(fullpath, '/', &p)); PetscCall(PetscStrncpy(path, p, flen)); PetscFunctionReturn(PETSC_SUCCESS); }