parent
14b5544d8b
commit
2e29e665bb
@ -6,13 +6,14 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "_hypre_utilities.h"
|
#include "_hypre_utilities.h"
|
||||||
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#define mkdir(path, mode) _mkdir(path)
|
#define mkdir(path, mode) _mkdir(path)
|
||||||
#else
|
#else
|
||||||
|
#include <dirent.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
@ -106,6 +107,7 @@ hypre_strcpy(char *destination, const char *source)
|
|||||||
HYPRE_Int
|
HYPRE_Int
|
||||||
hypre_CheckDirExists(const char *path)
|
hypre_CheckDirExists(const char *path)
|
||||||
{
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
DIR *dir = opendir(path);
|
DIR *dir = opendir(path);
|
||||||
|
|
||||||
if (dir)
|
if (dir)
|
||||||
@ -113,6 +115,20 @@ hypre_CheckDirExists(const char *path)
|
|||||||
closedir(dir);
|
closedir(dir);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
DWORD att = GetFileAttributesA(path);
|
||||||
|
|
||||||
|
if (att == INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (att & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,12 +157,15 @@ hypre_CreateDir(const char *path)
|
|||||||
HYPRE_Int
|
HYPRE_Int
|
||||||
hypre_CreateNextDirOfSequence(const char *basepath, const char *prefix, char **fullpath_ptr)
|
hypre_CreateNextDirOfSequence(const char *basepath, const char *prefix, char **fullpath_ptr)
|
||||||
{
|
{
|
||||||
DIR *dir;
|
HYPRE_Int suffix;
|
||||||
struct dirent *entry;
|
HYPRE_Int max_suffix = -1;
|
||||||
HYPRE_Int max_suffix, suffix;
|
|
||||||
char msg[HYPRE_MAX_MSG_LEN];
|
char msg[HYPRE_MAX_MSG_LEN];
|
||||||
char *fullpath;
|
char *fullpath;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent *entry;
|
||||||
|
|
||||||
if ((dir = opendir(basepath)) == NULL)
|
if ((dir = opendir(basepath)) == NULL)
|
||||||
{
|
{
|
||||||
hypre_sprintf(msg, "Could not open directory: %s", basepath);
|
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);
|
closedir(dir);
|
||||||
|
#else
|
||||||
|
/* TODO (VPM) */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Create directory */
|
/* Create directory */
|
||||||
fullpath = hypre_TAlloc(char, strlen(basepath) + 10, HYPRE_MEMORY_HOST);
|
fullpath = hypre_TAlloc(char, strlen(basepath) + 10, HYPRE_MEMORY_HOST);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user