forked from clshortfuse/renodx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'clshortfuse:main' into main
- Loading branch information
Showing
13 changed files
with
3,394 additions
and
2,945 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2024 Carlos Lopez | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <Windows.h> | ||
#include <cstdint> | ||
#include <filesystem> | ||
#include <fstream> | ||
#include <span> | ||
|
||
namespace renodx::utils::path { | ||
|
||
static std::filesystem::path GetOutputPath() { | ||
// NOLINTNEXTLINE(modernize-avoid-c-arrays) | ||
wchar_t file_prefix[MAX_PATH] = L""; | ||
GetModuleFileNameW(nullptr, file_prefix, ARRAYSIZE(file_prefix)); | ||
|
||
std::filesystem::path dump_path = file_prefix; | ||
dump_path = dump_path.parent_path(); | ||
dump_path /= "renodx-dev"; | ||
return dump_path; | ||
} | ||
|
||
static std::vector<uint8_t> ReadBinaryFile(const std::filesystem::path& path) { | ||
std::ifstream file(path, std::ios::binary); | ||
file.seekg(0, std::ios::end); | ||
const size_t file_size = file.tellg(); | ||
if (file_size == 0) return {}; | ||
|
||
auto result = std::vector<uint8_t>(file_size); | ||
file.seekg(0, std::ios::beg).read(reinterpret_cast<char*>(result.data()), file_size); | ||
return result; | ||
} | ||
|
||
static std::string ReadTextFile(const std::filesystem::path& path) { | ||
auto data = ReadBinaryFile(path); | ||
if (data.empty()) return ""; | ||
return {reinterpret_cast<const char*>(data.data()), data.size()}; | ||
} | ||
|
||
static void WriteBinaryFile(const std::filesystem::path& path, std::span<uint8_t> data) { | ||
std::ofstream file(path, std::ios::binary); | ||
file.write(reinterpret_cast<const char*>(data.data()), data.size()); | ||
} | ||
|
||
} // namespace renodx::utils::path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.