#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 .seealso: `PetscGetFullPath()` @*/ PetscErrorCode PetscGetRelativePath(const char fullpath[], char path[], size_t flen) { char *p; PetscFunctionBegin; /* Find string after last / or entire string if no / */ PetscCall(PetscStrrchr(fullpath, '/', &p)); PetscCall(PetscStrncpy(path, p, flen)); PetscFunctionReturn(PETSC_SUCCESS); }