Actual source code: ex31.c


  2: static char help[] = "Tests PetscGetFullPath().\n\n";

  4: #include <petscsys.h>

  6: /* for windows - fix up path - so that we can do diff test */
  7: PetscErrorCode  path_to_unix(char filein[])
  8: {
 10:   size_t         i,n;

 13:   PetscStrlen(filein,&n);
 14:   for (i=0; i<n; i++) {
 15:     if (filein[i] == '\\') filein[i] = '/';
 16:   }
 17:   return(0);
 18: }

 20: int main(int argc,char **argv)
 21: {
 22:   char           fpath[PETSC_MAX_PATH_LEN];

 25:   PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
 26:   PetscGetFullPath("~/somefile",fpath,sizeof(fpath));
 27:   path_to_unix(fpath);
 28:   PetscPrintf(PETSC_COMM_WORLD,"%s\n",fpath);
 29:   PetscGetFullPath("someotherfile",fpath,sizeof(fpath));
 30:   path_to_unix(fpath);
 31:   PetscPrintf(PETSC_COMM_WORLD,"%s\n",fpath);
 32:   PetscFinalize();
 33:   return ierr;
 34: }

 36: /*TEST

 38:    test:
 39:       requires: !windows_compilers
 40:       filter: sed "s?$(pwd -P)??g" |  sed "s?${HOME}??g"

 42:    test:
 43:       suffix: 2
 44:       requires: windows_compilers
 45:       output_file: output/ex31_1.out
 46:       filter: sed "s?`cygpath -m ${PWD}`??g" |  sed "s?`cygpath -m ${HOME}`??g"

 48: TEST*/