/* Code for manipulating files. */ #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_DIRECT_H) #include #endif #if defined(PETSC_HAVE_SYS_SYSTEMINFO_H) #include #endif /*@C PetscGetWorkingDirectory - Gets the current working directory. Not Collective Input Parameters: . len - maximum length of path Output Parameter: . path - use to hold the result value. The string should be long enough to hold the path. Level: developer @*/ PetscErrorCode PetscGetWorkingDirectory(char path[],size_t len) { PetscFunctionBegin; #if defined(PETSC_HAVE_GETCWD) if (!getcwd(path,len)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"getcwd()"); #elif defined(PETSC_HAVE__GETCWD) _getcwd(path,len); #elif defined(PETSC_HAVE_GETWD) getwd(path); #else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP_SYS, "Could not find getcwd() or getwd()"); #endif PetscFunctionReturn(0); }