Replaced the utility function to create a directory to std::filesystem.

This commit is contained in:
nodchip
2020-09-07 18:56:41 +09:00
parent e004e47e5a
commit 4cc98d80f8
4 changed files with 4 additions and 70 deletions

View File

@@ -39,6 +39,7 @@
#include <memory>
#include <limits>
#include <optional>
#include <filesystem>
#if defined (_OPENMP)
#include <omp.h>
@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -4,6 +4,7 @@
#include <random>
#include <fstream>
#include <filesystem>
#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"}});