From a150b17e33f7f97a1c5aef28b0127291e453b3db Mon Sep 17 00:00:00 2001 From: Jannis Maier Date: Wed, 2 Oct 2024 12:45:07 +0200 Subject: [PATCH] Update version to v0.21.34 --- CMakeLists.txt | 2 +- Intern/rayx-core/src/Data/Locate.cpp | 12 ++++---- Intern/rayx-core/src/Data/Locate.h | 29 ++++++++++++++++---- Intern/rayx-core/src/Material/NffTable.cpp | 2 +- Intern/rayx-core/src/Material/PalikTable.cpp | 2 +- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d4c58303..87e6cffb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.25.2 FATAL_ERROR) # ---- Project ---- -project(RAYX VERSION 0.21.33) +project(RAYX VERSION 0.21.34) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CUDA_STANDARD 20) diff --git a/Intern/rayx-core/src/Data/Locate.cpp b/Intern/rayx-core/src/Data/Locate.cpp index db539be9..61110152 100644 --- a/Intern/rayx-core/src/Data/Locate.cpp +++ b/Intern/rayx-core/src/Data/Locate.cpp @@ -15,10 +15,10 @@ namespace RAYX { // Check if a file exists -bool fileExists(const std::string& path) { return std::filesystem::exists(path); } -bool fileExists(const std::filesystem::path& path) { return std::filesystem::exists(path); } +bool ResourceFinder::fileExists(const std::string& path) { return std::filesystem::exists(path); } +bool ResourceFinder::fileExists(const std::filesystem::path& path) { return std::filesystem::exists(path); } -std::filesystem::path getExecutablePath() { +std::filesystem::path ResourceFinder::getExecutablePath() { #if defined(_WIN32) // Start with a reasonable buffer size std::vector buffer(MAX_PATH); @@ -59,7 +59,7 @@ std::filesystem::path getExecutablePath() { } // General method to get the full path based on the base directory (e.g., data or font directory) -std::filesystem::path getFullPath(const std::string& baseDir, const std::string& relativePath) { +std::filesystem::path ResourceFinder::getFullPath(const std::string& baseDir, const std::string& relativePath) { #if defined(__linux__) // First, check in /usr (package install) std::string path = std::string("/usr/") + baseDir + "/" + relativePath; @@ -89,9 +89,9 @@ std::filesystem::path getFullPath(const std::string& baseDir, const std::string& } // Retrieve the full path of a resource based on the platform -std::filesystem::path getResourcePath(const std::string& relativePath) { return getFullPath(RAYX_DATA_DIR, relativePath); } +std::filesystem::path ResourceFinder::getResourcePath(const std::string& relativePath) { return getFullPath(RAYX_DATA_DIR, relativePath); } // Retrieve the full path of a font based on the platform -std::filesystem::path getFontPath(const std::string& relativePath) { return getFullPath(RAYX_FONTS_DIR, relativePath); } +std::filesystem::path ResourceFinder::getFontPath(const std::string& relativePath) { return getFullPath(RAYX_FONTS_DIR, relativePath); } } // namespace RAYX \ No newline at end of file diff --git a/Intern/rayx-core/src/Data/Locate.h b/Intern/rayx-core/src/Data/Locate.h index f10bd068..64931f35 100644 --- a/Intern/rayx-core/src/Data/Locate.h +++ b/Intern/rayx-core/src/Data/Locate.h @@ -7,13 +7,30 @@ namespace RAYX { -// Platform-specific implementations for resource path search -RAYX_API std::filesystem::path getExecutablePath(); +class RAYX_API ResourceFinder { + public: + // Platform-specific implementations for resource path search + std::filesystem::path getExecutablePath(); -// Retrieves a resource file's full path based on the relative path -RAYX_API std::filesystem::path getResourcePath(const std::string& relativePath); + // Retrieves a resource file's full path based on the relative path + std::filesystem::path getResourcePath(const std::string& relativePath); -// Retrieves a font file's full path based on the relative path -RAYX_API std::filesystem::path getFontPath(const std::string& relativePath); + // Retrieves a font file's full path based on the relative path + std::filesystem::path getFontPath(const std::string& relativePath); + + private: + bool fileExists(const std::string& path); + bool fileExists(const std::filesystem::path& path); + std::filesystem::path getFullPath(const std::string& baseDir, const std::string& relativePath); + + std::vector lookUpPaths = { +#if defined(__linux__) + std::filesystem::path("/usr"), // + std::filesystem::path("/usr/local"), // +#elif defined(_WIN32) +#elif defined(__APPLE__) +#endif + }; +}; } // namespace RAYX \ No newline at end of file diff --git a/Intern/rayx-core/src/Material/NffTable.cpp b/Intern/rayx-core/src/Material/NffTable.cpp index c459b77f..d16d486f 100644 --- a/Intern/rayx-core/src/Material/NffTable.cpp +++ b/Intern/rayx-core/src/Material/NffTable.cpp @@ -14,7 +14,7 @@ bool NffTable::load(const char* element, NffTable* out) { std::transform(elementString.begin(), elementString.end(), elementString.begin(), [](unsigned char c) { return std::tolower(c); }); - std::filesystem::path f = getResourcePath("nff/" + elementString + ".nff"); + std::filesystem::path f = getResourcePath("Data/nff/" + elementString + ".nff"); RAYX_VERB << "Loading NffTable from " << f; std::ifstream s(f); diff --git a/Intern/rayx-core/src/Material/PalikTable.cpp b/Intern/rayx-core/src/Material/PalikTable.cpp index 71dba544..b6288761 100644 --- a/Intern/rayx-core/src/Material/PalikTable.cpp +++ b/Intern/rayx-core/src/Material/PalikTable.cpp @@ -12,7 +12,7 @@ bool PalikTable::load(const char* element, PalikTable* out) { std::string elementString = element; std::transform(elementString.begin(), elementString.end(), elementString.begin(), [](unsigned char c) { return std::toupper(c); }); - std::filesystem::path f = getResourcePath("PALIK/" + elementString + ".NKP"); + std::filesystem::path f = getResourcePath("Data/PALIK/" + elementString + ".NKP"); RAYX_VERB << "Loading PalikTable from " << f; std::ifstream s(f);