From fbdb373b6482db2b462b30d7399c3c7fed1d4f26 Mon Sep 17 00:00:00 2001 From: nodchip Date: Mon, 20 Jul 2020 17:17:50 +0900 Subject: [PATCH] Changed to set the binary directory to the current working directory. --- src/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index fafefee2..6001432d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,15 @@ #include +#ifdef _WIN32 +#include + +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +#endif + #include "bitboard.h" #include "endgame.h" #include "position.h" @@ -34,6 +43,17 @@ namespace PSQT { } int main(int argc, char* argv[]) { + // Change the current working directory to the binary directory. So that a + // net file path can be specified with a relative path from the binary + // directory. + // TODO(someone): Implement the logic for other OS. +#ifdef _WIN32 + TCHAR filename[_MAX_PATH]; + ::GetModuleFileName(NULL, filename, sizeof(filename) / sizeof(filename[0])); + std::filesystem::path current_path = filename; + current_path.remove_filename(); + std::filesystem::current_path(current_path); +#endif std::cout << engine_info() << std::endl;