mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 20:57:10 +00:00
Replaced the utility function to create a directory to std::filesystem.
This commit is contained in:
@@ -39,6 +39,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#if defined (_OPENMP)
|
#if defined (_OPENMP)
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
@@ -1467,7 +1468,7 @@ namespace Learner
|
|||||||
cout << ".";
|
cout << ".";
|
||||||
};
|
};
|
||||||
|
|
||||||
Dependency::mkdir("tmp");
|
std::filesystem::create_directory("tmp");
|
||||||
|
|
||||||
// Shuffle and export as a 10M phase shredded file.
|
// Shuffle and export as a 10M phase shredded file.
|
||||||
for (auto filename : filenames)
|
for (auto filename : filenames)
|
||||||
|
|||||||
@@ -687,66 +687,3 @@ int write_memory_to_file(std::string filename, void* ptr, uint64_t size)
|
|||||||
fs.close();
|
fs.close();
|
||||||
return 0;
|
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
|
|
||||||
|
|||||||
@@ -273,11 +273,6 @@ namespace Dependency
|
|||||||
// So when calling getline() on fstream,
|
// So when calling getline() on fstream,
|
||||||
// just write getline() instead of std::getline() and use this function.
|
// just write getline() instead of std::getline() and use this function.
|
||||||
extern bool getline(std::ifstream& fs, std::string& s);
|
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
|
#endif // #ifndef MISC_H_INCLUDED
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include "../learn/learn.h"
|
#include "../learn/learn.h"
|
||||||
#include "../learn/learning_tools.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
|
// mkdir() will fail if this folder already exists, but
|
||||||
// Apart from that. If not, I just want you to make it.
|
// Apart from that. If not, I just want you to make it.
|
||||||
// Also, assume that the folders up to EvalSaveDir have been dug.
|
// 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) {
|
if (Options["SkipLoadingEval"] && NNUE::trainer) {
|
||||||
NNUE::SendMessages({{"clear_unobserved_feature_weights"}});
|
NNUE::SendMessages({{"clear_unobserved_feature_weights"}});
|
||||||
|
|||||||
Reference in New Issue
Block a user