diff --git a/.gitignore b/.gitignore index 57cbdad..18f568a 100644 --- a/.gitignore +++ b/.gitignore @@ -337,3 +337,7 @@ $RECYCLE.BIN/ *.lnk *.exe +# Cmake files +CMakeCache.txt +CmakeLists.txt +CMakeFiles diff --git a/OcapReplaySaver2/CmakeLists.txt b/OcapReplaySaver2/CmakeLists.txt index f1512c7..5c3ed0c 100644 --- a/OcapReplaySaver2/CmakeLists.txt +++ b/OcapReplaySaver2/CmakeLists.txt @@ -25,8 +25,9 @@ add_library(OcapReplaySaver2 SHARED include_directories(include) -target_link_libraries(OcapReplaySaver2 CURL::libcurl) -target_link_libraries(OcapReplaySaver2 ZLIB::ZLIB) +target_link_libraries(OcapReplaySaver2 ${CURL_LIBRARIES}) +target_link_libraries(OcapReplaySaver2 ${ZLIB_LIBRARIES}) +target_link_libraries(OcapReplaySaver2 stdc++fs) IF (WIN32) ELSE() diff --git a/OcapReplaySaver2/OcapReplaySaver2.cfg.json b/OcapReplaySaver2/OcapReplaySaver2.cfg.json index cbcdb4f..79e7455 100644 --- a/OcapReplaySaver2/OcapReplaySaver2.cfg.json +++ b/OcapReplaySaver2/OcapReplaySaver2.cfg.json @@ -2,6 +2,7 @@ "httpRequestTimeout": 120, "logAndTmpPrefix": "ocap-", "logsDir": "./OCAPLOG", + "tempDir": "./OCAPTMP", "newServerGameType": "TvT", "newUrl": "http://127.0.0.1/api/v1/operations/add", "newUrlRequestSecret": "pwd1234", diff --git a/OcapReplaySaver2/OcapReplaySaver2.cpp b/OcapReplaySaver2/OcapReplaySaver2.cpp index ad3415c..248eac9 100644 --- a/OcapReplaySaver2/OcapReplaySaver2.cpp +++ b/OcapReplaySaver2/OcapReplaySaver2.cpp @@ -1,7 +1,7 @@ // by Zealot // MIT licence https://opensource.org/licenses/MIT -#define CURRENT_VERSION "4.4.2.3" +#define CURRENT_VERSION "4.4.3.0" #include #include @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef _WIN32 #include @@ -144,6 +145,7 @@ namespace { int httpRequestTimeout{ 120 }; int traceLog{ 0 }; std::string logsDir{ "./OCAPLOG" }; + std::string tempDir{ "./OCAPTMP" }; std::string logAndTmpPrefix{ "ocap-" }; // TODO: new names and comments, logs dir, change types accordingly, chenage default values } config; @@ -461,6 +463,20 @@ fs::path getAndCreateLogDirectory() { return res; } +fs::path getAndCreateTempDirectory() { + fs::path res = config.tempDir; + //res += "/"; + //res += "OCAPLOG"; + res.make_preferred(); + try { + fs::create_directories(res); + } + catch (const std::exception& ex) { + LOG(WARNING) << "Error create directories: " << ex.what(); + } + return res; +} + std::string uniqueFileName() { std::srand(std::time(nullptr)); std::string res(5, '\0'); @@ -473,7 +489,7 @@ std::string uniqueFileName() { } pair > saveCurrentReplayToTempFile() { - fs::path temp_fname = fs::temp_directory_path(); + fs::path temp_fname = getAndCreateTempDirectory(); temp_fname += "/"; temp_fname += config.logAndTmpPrefix; diff --git a/build-docker-ubuntu.sh b/build-docker-ubuntu.sh new file mode 100644 index 0000000..9fdc46a --- /dev/null +++ b/build-docker-ubuntu.sh @@ -0,0 +1,17 @@ +docker run --rm --platform linux/amd64 -it -v .:/build ubuntu:20.04 bash -c '\ + apt-get update &&\ + apt-get install -y build-essential cmake g++ libcurl4-openssl-dev zlib1g-dev &&\ + cd /build/OcapReplaySaver2 &&\ + cmake . &&\ + make &&\ + mkdir -p /build/build/ubuntu_20.04/ + cp OcapReplaySaver2_x64.so /build/build/ubuntu_20.04/' + +docker run --rm --platform linux/amd64 -it -v .:/build ubuntu:22.04 bash -c '\ + apt-get update &&\ + apt-get install -y build-essential cmake g++ libcurl4-openssl-dev zlib1g-dev &&\ + cd /build/OcapReplaySaver2 &&\ + cmake . &&\ + make &&\ + mkdir -p /build/build/ubuntu_22.04/ + cp OcapReplaySaver2_x64.so /build/build/ubuntu_22.04/' \ No newline at end of file