Skip to content

Commit

Permalink
Update version to v0.21.34
Browse files Browse the repository at this point in the history
  • Loading branch information
Atraxus committed Oct 2, 2024
1 parent 88375d9 commit a150b17
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
12 changes: 6 additions & 6 deletions Intern/rayx-core/src/Data/Locate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char> buffer(MAX_PATH);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
29 changes: 23 additions & 6 deletions Intern/rayx-core/src/Data/Locate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::filesystem::path> lookUpPaths = {
#if defined(__linux__)
std::filesystem::path("/usr"), //
std::filesystem::path("/usr/local"), //
#elif defined(_WIN32)
#elif defined(__APPLE__)
#endif
};
};

} // namespace RAYX
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Material/NffTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Material/PalikTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a150b17

Please sign in to comment.