diff --git a/CMakeLists.txt b/CMakeLists.txt index d9e5a8a..bf818c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ find_package(boost_lexical_cast CONFIG REQUIRED) find_package(boost_uuid CONFIG REQUIRED) find_package(nlohmann_json REQUIRED) find_package(glog REQUIRED) +find_package(fmt CONFIG REQUIRED) # Organization info set(PROJECT_ORG_NAME "Cadons") diff --git a/lib/tusclient/CMakeLists.txt b/lib/tusclient/CMakeLists.txt index 9041299..fce6bc3 100644 --- a/lib/tusclient/CMakeLists.txt +++ b/lib/tusclient/CMakeLists.txt @@ -18,7 +18,7 @@ target_include_directories(tusclient PUBLIC $) # Link libraries -target_link_libraries(tusclient PUBLIC CURL::libcurl Boost::uuid Boost::lexical_cast nlohmann_json::nlohmann_json glog::glog) +target_link_libraries(tusclient PUBLIC CURL::libcurl Boost::uuid Boost::lexical_cast nlohmann_json::nlohmann_json glog::glog fmt::fmt) if(BUILD_SHARED_LIBS) target_compile_definitions(tusclient PRIVATE TUSCLIENT_EXPORTS) target_compile_definitions(tusclient PRIVATE TUSCLIENT_SHARED) diff --git a/lib/tusclient/LICENSE b/lib/tusclient/LICENSE deleted file mode 100644 index 75110a2..0000000 --- a/lib/tusclient/LICENSE +++ /dev/null @@ -1,34 +0,0 @@ -tusclient - End User License Agreement (EULA) -Copyright (c) Unknown Organization - -IMPORTANT: PLEASE READ THIS AGREEMENT CAREFULLY BEFORE USING THIS SOFTWARE. - -By installing, copying, or otherwise using tusclient (the "Software"), you agree to be bound by the terms of this EULA. - -1. LICENSE GRANT -Unknown Organization grants you a non-exclusive, non-transferable license to use the Software solely for your personal or internal business purposes, subject to the terms of this Agreement. - -2. RESTRICTIONS -You may not: -- Modify, reverse engineer, decompile, or disassemble the Software. -- Distribute, sell, sublicense, or rent the Software to any third party. -- Remove any proprietary notices or labels on the Software. - -3. OWNERSHIP -The Software is licensed, not sold. Unknown Organization retains all rights, title, and interest in and to the Software. - -4. TERMINATION -This Agreement is effective until terminated. You may terminate it by deleting the Software. It will also terminate if you fail to comply with any terms herein. - -5. WARRANTY DISCLAIMER -The Software is provided "AS IS" without warranty of any kind. Unknown Organization disclaims all warranties, express or implied, including but not limited to fitness for a particular purpose. - -6. LIMITATION OF LIABILITY -In no event shall Unknown Organization be liable for any damages arising from the use or inability to use the Software. - -7. GOVERNING LAW -This Agreement shall be governed by the laws of the jurisdiction where Unknown Organization is located. - -If you do not agree to these terms, do not install or use the Software. - -For questions, contact: Unknown Organization - None \ No newline at end of file diff --git a/lib/tusclient/src/tusclient/TusClient.cpp b/lib/tusclient/src/tusclient/TusClient.cpp index 5ffbcec..22d121d 100644 --- a/lib/tusclient/src/tusclient/TusClient.cpp +++ b/lib/tusclient/src/tusclient/TusClient.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include "TusClient.h" #include "cache/CacheRepository.h" @@ -154,7 +154,7 @@ bool TusClient::upload() { m_tusLocation.replace(0, lastSlashPosition + 1, ""); } else { // Handle the case where '/' is not found in m_tusLocation - std::cerr << std::format("Invalid upload URL: The URL is empty or invalid.\n" + std::cerr << fmt::format("Invalid upload URL: The URL is empty or invalid.\n" "Please ensure the URL is a complete TUS server endpoint (e.g., 'http://localhost:8080/files/')\n" "Current URL: '{}'\n", m_url) << std::endl; } @@ -234,7 +234,7 @@ void TusClient::handleUploadConflict(const string &header) { m_logger->warning("Conflict detected, retrying the upload"); getUploadInfo(); } else { - m_logger->error(std::format("Error: Too many conflicts {}", m_uploadedChunks)); + m_logger->error(fmt::format("Error: Too many conflicts {}", m_uploadedChunks)); m_logger->error(header); m_status.store(TusStatus::FAILED); throw TUS::Exceptions::TUSException("Error: Too many conflicts"); @@ -243,7 +243,7 @@ void TusClient::handleUploadConflict(const string &header) { } void TusClient::handleUploadError(const string &header) { - m_logger->error(std::format("Error: Unable to upload chunk {}", m_uploadedChunks)); + m_logger->error(fmt::format("Error: Unable to upload chunk {}", m_uploadedChunks)); m_logger->error(header); m_status.store(TusStatus::FAILED); throw TUS::Exceptions::TUSException("Error: Unable to upload chunk"); @@ -284,7 +284,7 @@ void TusClient::uploadChunk(int chunkNumber) { throw TUS::Exceptions::TUSException("Error: Unable to upload chunk"); } }; - m_logger->debug(std::format("Uploading chunk {}", chunkNumber)); + m_logger->debug(fmt::format("Uploading chunk {}", chunkNumber)); m_httpClient->patch(Http::Request( m_url + m_tusLocation, std::string(reinterpret_cast(chunk.getData().data()), diff --git a/lib/tusclient/src/tusclient/chunk/FileChunker.cpp b/lib/tusclient/src/tusclient/chunk/FileChunker.cpp index 816feaf..361995b 100644 --- a/lib/tusclient/src/tusclient/chunk/FileChunker.cpp +++ b/lib/tusclient/src/tusclient/chunk/FileChunker.cpp @@ -13,7 +13,7 @@ #include "chunk/TUSChunk.h" #include "chunk/utility/ChunkUtility.h" #include "verifiers/Md5Verifier.h" -#include +#include using TUS::Chunk::FileChunker; using TUS::Chunk::TUSChunk; @@ -67,7 +67,7 @@ std::filesystem::path FileChunker::getTemporaryDir() const { } std::string FileChunker::getChunkFilename(int chunkNumber) const { - return std::format("{}{}{}{}", m_uuid, CHUNK_FILE_NAME_PREFIX, chunkNumber, CHUNK_FILE_EXTENSION); + return fmt::format("{}{}{}{}", m_uuid, CHUNK_FILE_NAME_PREFIX, chunkNumber, CHUNK_FILE_EXTENSION); } std::filesystem::path FileChunker::getChunkFilePath(int chunkNumber) const { diff --git a/lib/tusclient/src/tusclient/verifiers/Md5Verifier.cpp b/lib/tusclient/src/tusclient/verifiers/Md5Verifier.cpp index df67de5..baec0c3 100644 --- a/lib/tusclient/src/tusclient/verifiers/Md5Verifier.cpp +++ b/lib/tusclient/src/tusclient/verifiers/Md5Verifier.cpp @@ -8,7 +8,7 @@ #include #include #include - +#include #include "verifiers/Md5Verifier.h" @@ -28,7 +28,7 @@ string Md5Verifier::hash(const std::vector &buffer) const { std::string result; for (const unsigned char i : digest) { - result += std::format("{:02x}", static_cast(i)); + result += fmt::format("{:02x}", static_cast(i)); } return result; } diff --git a/lib/tusclient/test/TusClientTest.cpp b/lib/tusclient/test/TusClientTest.cpp index 74addb6..76819c8 100644 --- a/lib/tusclient/test/TusClientTest.cpp +++ b/lib/tusclient/test/TusClientTest.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include "TusClient.h" /** @@ -36,7 +36,7 @@ namespace TUS::Test { std::filesystem::remove("test.zip"); for (int i = 0; i < MAX_CLEANUP_FILES; ++i) { - std::filesystem::remove(std::format("{}.dat", i)); + std::filesystem::remove(fmt::format("{}.dat", i)); } } private: @@ -65,7 +65,7 @@ namespace TUS::Test { return static_cast(dis(gen)); }); - std::ofstream datFile(std::format("{}.dat", i), std::ios::binary); + std::ofstream datFile(fmt::format("{}.dat", i), std::ios::binary); datFile.write(data.data(), data.size()); }); } @@ -76,12 +76,12 @@ namespace TUS::Test { zipArchive.open(libzippp::ZipArchive::New); for (int i = 0; i < size; ++i) { - zipArchive.addFile(std::to_string(i), std::format("{}.dat", i)); + zipArchive.addFile(std::to_string(i), fmt::format("{}.dat", i)); } zipArchive.close(); for (int i = 0; i < size; ++i) { - std::filesystem::remove(std::format("{}.dat", i)); + std::filesystem::remove(fmt::format("{}.dat", i)); } return "test.zip"; diff --git a/project.json b/project.json index 39c149d..2c3997b 100644 --- a/project.json +++ b/project.json @@ -1,5 +1,5 @@ { - "name": "tusclient", + "name": "cadons-ctus", "organization": "Cadons", "package_manager": "vcpkg", "version": "1.0.0", diff --git a/vcpkg.json b/vcpkg.json index f4394d1..670bf71 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,5 +1,5 @@ { - "name": "tusclient", + "name": "cadons-ctus", "license": "MIT", "version": "1.0.0", "description": "Library implementing the tus protocol for resumable uploads", @@ -34,16 +34,8 @@ }, { "name": "glog" - }, - "vcpkg-cmake", - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "features": { - "shared": { - "description": "Build shared libraries" + },{ + "name": "fmt" } - } + ] } \ No newline at end of file