1+ // Copyright (c) Nouman Tajik [github.com/tajiknomi]
2+ //
3+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4+ // of this software and associated documentation files (the "Software"), to deal
5+ // in the Software without restriction, including without limitation the rights
6+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+ // copies of the Software, and to permit persons to whom the Software is
8+ // furnished to do so, subject to the following conditions:
9+ //
10+ // The above copyright notice and this permission notice shall be included in all
11+ // copies or substantial portions of the Software.
12+ //
13+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+ // SOFTWARE.
20+
21+ #pragma once
22+
23+ #include < string>
24+
25+
26+ #if __has_include(<filesystem>)
27+ #include < filesystem>
28+ namespace fs = std::filesystem;
29+ #elif __has_include(<experimental/filesystem>)
30+ #include < experimental/filesystem>
31+ namespace fs = std::experimental::filesystem;
32+ #else
33+ #error "Neither <filesystem> nor <experimental/filesystem> are available."
34+ #endif
35+
36+
37+ class curlFileTransfer {
38+
39+ private:
40+ static bool isDataServerAvailable (const std::string& url);
41+ static size_t WriteData (void * buffer, size_t size, size_t nmemb, void * userp);
42+ static size_t WriteCallback (void * contents, size_t size, size_t nmemb, void * userp);
43+
44+ public:
45+ static bool DownloadFileFromURL (const std::wstring& url, const std::wstring& outputDirPath);
46+ static bool DownloadDirectoryFromURL (const std::wstring& url, const std::wstring& outputDirPath);
47+ static bool UploadFileToURL (const std::wstring& url, const std::wstring& filePath);
48+ static bool UploadDirectoryToURL (const std::wstring& url, const std::wstring& dirPath, std::wstring &errorMsg, const std::wstring& extensions);
49+ };
0 commit comments