diff --git a/src/utilities/utilities.c b/src/utilities/utilities.c index 878db97a1..eb6305a4d 100644 --- a/src/utilities/utilities.c +++ b/src/utilities/utilities.c @@ -6,13 +6,14 @@ ******************************************************************************/ #include "_hypre_utilities.h" - -#include #include + #ifdef _WIN32 +#include #include #define mkdir(path, mode) _mkdir(path) #else +#include #include #include #endif @@ -106,6 +107,7 @@ hypre_strcpy(char *destination, const char *source) HYPRE_Int hypre_CheckDirExists(const char *path) { +#ifndef _WIN32 DIR *dir = opendir(path); if (dir) @@ -113,6 +115,20 @@ hypre_CheckDirExists(const char *path) closedir(dir); return 1; } +#else + DWORD att = GetFileAttributesA(path); + + if (att == INVALID_FILE_ATTRIBUTES) + { + return 0; + } + + if (att & FILE_ATTRIBUTE_DIRECTORY) + { + return 1; + } +#endif + return 0; } @@ -141,12 +157,15 @@ hypre_CreateDir(const char *path) HYPRE_Int hypre_CreateNextDirOfSequence(const char *basepath, const char *prefix, char **fullpath_ptr) { - DIR *dir; - struct dirent *entry; - HYPRE_Int max_suffix, suffix; + HYPRE_Int suffix; + HYPRE_Int max_suffix = -1; char msg[HYPRE_MAX_MSG_LEN]; char *fullpath; +#ifndef _WIN32 + DIR *dir; + struct dirent *entry; + if ((dir = opendir(basepath)) == NULL) { hypre_sprintf(msg, "Could not open directory: %s", basepath); @@ -169,6 +188,9 @@ hypre_CreateNextDirOfSequence(const char *basepath, const char *prefix, char **f } } closedir(dir); +#else + /* TODO (VPM) */ +#endif /* Create directory */ fullpath = hypre_TAlloc(char, strlen(basepath) + 10, HYPRE_MEMORY_HOST);