mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-25 11:36:51 +08:00
Replaced the utility function to create a directory to std::filesystem.
This commit is contained in:
63
src/misc.cpp
63
src/misc.cpp
@@ -687,66 +687,3 @@ int write_memory_to_file(std::string filename, void* ptr, uint64_t size)
|
||||
fs.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
// mkdir wrapper
|
||||
// ----------------------------
|
||||
|
||||
// Specify relative to the current folder. Returns 0 on success, non-zero on failure.
|
||||
// Create a folder. Japanese is not used.
|
||||
// In case of gcc under msys2 environment, folder creation fails with _wmkdir(). Cause unknown.
|
||||
// Use _mkdir() because there is no help for it.
|
||||
|
||||
#if defined(_WIN32)
|
||||
// for Windows
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <codecvt> // I need this because I want wstring to mkdir
|
||||
#include <locale> // This is required for wstring_convert.
|
||||
|
||||
namespace Dependency {
|
||||
int mkdir(std::string dir_name)
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> cv;
|
||||
return _wmkdir(cv.from_bytes(dir_name).c_str());
|
||||
// ::CreateDirectory(cv.from_bytes(dir_name).c_str(),NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
#include <direct.h>
|
||||
namespace Dependency {
|
||||
int mkdir(std::string dir_name)
|
||||
{
|
||||
return _mkdir(dir_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#elif defined(__linux__)
|
||||
|
||||
// In the linux environment, this symbol _LINUX is defined in the makefile.
|
||||
|
||||
// mkdir implementation for Linux.
|
||||
#include "sys/stat.h"
|
||||
|
||||
namespace Dependency {
|
||||
int mkdir(std::string dir_name)
|
||||
{
|
||||
return ::mkdir(dir_name.c_str(), 0777);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
// In order to judge whether it is a Linux environment, we have to divide the makefile..
|
||||
// The function to dig a folder on linux is good for the time being... Only used to save the evaluation function file...
|
||||
|
||||
namespace Dependency {
|
||||
int mkdir(std::string /* dir_name */)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user