#include <cstdarg>
#include <cstring>
#include <ctime>
+#include <filesystem>
#include <fstream>
#include <iostream>
#include <iterator>
#ifdef __linux__
#include <linux/limits.h>
#elif defined(_WIN32)
-#define PATH_MAX MAX_PATH
+# if !defined(PATH_MAX)
+# define PATH_MAX MAX_PATH
+# endif
#else
#include <sys/syslimits.h>
#endif
#endif
// Check if the file already exists locally
- struct stat model_file_info;
- auto file_exists = (stat(path.c_str(), &model_file_info) == 0);
+ auto file_exists = std::filesystem::exists(path);
// If the file exists, check its JSON metadata companion file.
std::string metadata_path = path + ".json";
#if defined(_WIN32)
# include <windows.h>
+# include <io.h>
#else
# include <sys/file.h>
# include <sys/ioctl.h>
return 1;
}
- OVERLAPPED overlapped = { 0 };
+ OVERLAPPED overlapped = {};
if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, MAXDWORD, MAXDWORD,
&overlapped)) {
fd = -1;
if (fd >= 0) {
# ifdef _WIN32
if (hFile != INVALID_HANDLE_VALUE) {
- OVERLAPPED overlapped = { 0 };
+ OVERLAPPED overlapped = {};
UnlockFileEx(hFile, 0, MAXDWORD, MAXDWORD, &overlapped);
}
# else
private:
int fd = -1;
# ifdef _WIN32
- HANDLE hFile;
+ HANDLE hFile = nullptr;
# endif
};
return (now_downloaded_plus_file_size * 100) / total_to_download;
}
- static std::string generate_progress_prefix(curl_off_t percentage) { return fmt("%3ld%% |", percentage); }
+ static std::string generate_progress_prefix(curl_off_t percentage) { return fmt("%3ld%% |", static_cast<long int>(percentage)); }
static double calculate_speed(curl_off_t now_downloaded, const std::chrono::steady_clock::time_point & start_time) {
const auto now = std::chrono::steady_clock::now();
cl_image_format img_fmt_1d;
cl_image_desc img_desc_1d;
cl_buffer_region region;
- cl_mem A_image1d;
- cl_mem B_image1d;
- cl_mem B_sub_buffer;
- cl_mem C_d;
+ cl_mem A_image1d = nullptr;
+ cl_mem B_image1d = nullptr;
+ cl_mem B_sub_buffer = nullptr;
+ cl_mem C_d = nullptr;
// for B transpose
- cl_mem B_d;
- cl_mem B_d_input_image;
+ cl_mem B_d = nullptr;
+ cl_mem B_d_input_image = nullptr;
// <--------------------------------------------> //
// define matrix dimensions