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: {
  9:   size_t         i,n;

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

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

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

 33: /*TEST

 35:    test:
 36:       requires: !windows_compilers
 37:       filter: sed "s?$(pwd -P)??g" |  sed "s?${HOME}??g"

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

 45: TEST*/