diff --git a/src/learn/learner.cpp b/src/learn/learner.cpp index 88f2a0c3..7021fd7f 100644 --- a/src/learn/learner.cpp +++ b/src/learn/learner.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #if defined (_OPENMP) #include @@ -1467,7 +1468,7 @@ namespace Learner cout << "."; }; - Dependency::mkdir("tmp"); + std::filesystem::create_directory("tmp"); // Shuffle and export as a 10M phase shredded file. for (auto filename : filenames) diff --git a/src/misc.cpp b/src/misc.cpp index 5c2a4637..a23b1205 100644 --- a/src/misc.cpp +++ b/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 // I need this because I want wstring to mkdir -#include // This is required for wstring_convert. - -namespace Dependency { - int mkdir(std::string dir_name) - { - std::wstring_convert, 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 -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 diff --git a/src/misc.h b/src/misc.h index d73d0633..c918a351 100644 --- a/src/misc.h +++ b/src/misc.h @@ -273,11 +273,6 @@ namespace Dependency // So when calling getline() on fstream, // just write getline() instead of std::getline() and use this function. extern bool getline(std::ifstream& fs, std::string& s); - - // Create a folder. - // Specify relative to the current folder. Japanese is not used for dir_name. - // Returns 0 on success, non-zero on failure. - extern int mkdir(std::string dir_name); } #endif // #ifndef MISC_H_INCLUDED diff --git a/src/nnue/evaluate_nnue_learner.cpp b/src/nnue/evaluate_nnue_learner.cpp index 650f443e..13d9d578 100644 --- a/src/nnue/evaluate_nnue_learner.cpp +++ b/src/nnue/evaluate_nnue_learner.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "../learn/learn.h" #include "../learn/learning_tools.h" @@ -207,7 +208,7 @@ void save_eval(std::string dir_name) { // mkdir() will fail if this folder already exists, but // Apart from that. If not, I just want you to make it. // Also, assume that the folders up to EvalSaveDir have been dug. - Dependency::mkdir(eval_dir); + std::filesystem::create_directories(eval_dir); if (Options["SkipLoadingEval"] && NNUE::trainer) { NNUE::SendMessages({{"clear_unobserved_feature_weights"}});