Actual source code: rpath.c

  1: /*$Id: rpath.c,v 1.31 2001/03/23 23:20:30 balay Exp $*/

 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(PARCH_win32)
 18: #include <sys/utsname.h>
 19: #endif
 20: #if defined(PARCH_win32)
 21: #include <windows.h>
 22: #include <io.h>
 23: #include <direct.h>
 24: #endif
 25: #if defined (PARCH_win32_gnu)
 26: #include <windows.h>
 27: #endif
 28: #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H)
 29: #include <sys/systeminfo.h>
 30: #endif
 31: #include "petscfix.h"

 33: #undef __FUNCT__  
 35: /*@C
 36:    PetscGetRelativePath - Given a filename, returns the relative path (removes
 37:    all directory specifiers).

 39:    Not Collective

 41:    Input parameters:
 42: +  fullpath  - full pathname
 43: .  path      - pointer to buffer to hold relative pathname
 44: -  flen     - size of path

 46:    Level: developer

 48:    Concepts: relative path
 49:    Concepts: path^relative

 51: .seealso: PetscGetFullPath()
 52: @*/
 53: int PetscGetRelativePath(const char fullpath[],char path[],int flen)
 54: {
 55:   char  *p;
 56:   int   ierr;

 59:   /* Find string after last / or entire string if no / */
 60:   PetscStrrchr(fullpath,'/',&p);
 61:   PetscStrncpy(path,p,flen);
 62:   return(0);
 63: }