/* 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 #include /*@C PetscGetWorkingDirectory - Gets the current working directory. Not Collective Input Parameter: . len - maximum length of `path` Output Parameter: . path - holds the result value. The string should be long enough to hold the path, for example, `PETSC_MAX_PATH_LEN` Level: developer .seealso: `PetscGetTmp()`, `PetscSharedTmp()`, `PetscSharedWorkingDirectory()`, `PetscGetHomeDirectory()` @*/ PetscErrorCode PetscGetWorkingDirectory(char path[], size_t len) { PetscFunctionBegin; #if defined(PETSC_HAVE_GETCWD) PetscCheck(getcwd(path, len), PETSC_COMM_SELF, PETSC_ERR_LIB, "Error in getcwd() due to \"%s\"", strerror(errno)); #elif defined(PETSC_HAVE__GETCWD) _getcwd(path, len); #else SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP_SYS, "Could not find getcwd()"); #endif PetscFunctionReturn(PETSC_SUCCESS); }