Skip to content

Commit

Permalink
fix: clean
Browse files Browse the repository at this point in the history
  • Loading branch information
vansangpfiev committed Sep 5, 2024
1 parent e950285 commit de3cfdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 10 additions & 6 deletions engine/commands/cortex_upd_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
#endif

namespace commands {

namespace {
const std::string kCortexBinary = "cortex-cpp";
}

CortexUpdCmd::CortexUpdCmd() {}

void CortexUpdCmd::Exec() {
std::cout << "1" << std::endl;
// Check if the architecture and OS are supported
auto system_info = system_info_utils::GetSystemInfo();
if (system_info.arch == system_info_utils::kUnsupported ||
Expand Down Expand Up @@ -122,19 +126,19 @@ void CortexUpdCmd::Exec() {
return;
}
#if defined(_WIN32)
std::string temp = ".\\cortex-cpp_tmp.exe";
std::string temp = ".\\cortex_tmp.exe";
remove(temp.c_str()); // ignore return code

std::string src = ".\\misc\\cortex-cpp\\cortex-cpp.exe";
std::string dst = ".\\cortex-cpp.exe";
std::string src = ".\\Cortex\\" + kCortexBinary + "\\" + kCortexBinary + ".exe";
std::string dst = ".\\" + kCortexBinary + ".exe";
// Rename
rename(dst.c_str(), temp.c_str());
// Update
CopyFile(const_cast<char*>(src.c_str()), const_cast<char*>(dst.c_str()),
false);
#else
std::string src = "./misc/cortex-cpp/cortex-cpp";
std::string dst = "./cortex-cpp";
std::string src = "./Cortex/" + kCortexBinary + "/" + kCortexBinary;
std::string dst = "./" + kCortexBinary;
std::filesystem::copy_file(src, dst,
std::filesystem::copy_options::overwrite_existing);
#endif
Expand Down
6 changes: 5 additions & 1 deletion engine/utils/file_manager_utils.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include "logging_utils.h"
#include <filesystem>
#include <string>
#include <string_view>
#include "logging_utils.h"

#if defined(__APPLE__) && defined(__MACH__)
#include <mach-o/dyld.h>
Expand Down Expand Up @@ -61,6 +61,8 @@ inline std::filesystem::path GetContainerFolderPath(
container_folder_path = current_path / "engines";
} else if (type == "CudaToolkit") {
container_folder_path = current_path;
} else if (type == "Cortex") {
container_folder_path = current_path / "cortex";
} else {
container_folder_path = current_path / "misc";
}
Expand All @@ -83,6 +85,8 @@ inline std::string downloadTypeToString(DownloadType type) {
return "Misc";
case DownloadType::CudaToolkit:
return "CudaToolkit";
case DownloadType::Cortex:
return "Cortex";
default:
return "UNKNOWN";
}
Expand Down

0 comments on commit de3cfdd

Please sign in to comment.