Actual source code: ex31.c
petsc-3.12.4 2020-02-04
Report Typos and Errors

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

      5:  #include <petscsys.h>

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

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

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

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

     39: /*TEST

     41:    test:
     42:       requires: !windows_compilers
     43:       filter: sed "s?$(pwd -P)??g" |  sed "s?${HOME}??g"

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

     51: TEST*/