-
Notifications
You must be signed in to change notification settings - Fork 88
add build and platform support for Haiku #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -224,6 +224,75 @@ std::string Platform::FindStateCacheFolder() { | |
| return home_path; | ||
| } | ||
|
|
||
| #elif __HAIKU__ | ||
| #include <Directory.h> | ||
| #include <Entry.h> | ||
| #include <FindDirectory.h> | ||
| #include <fs_info.h> | ||
|
|
||
| std::string Platform::FindResourceFolder() { | ||
| static std::string found_path; | ||
| static bool found = false; | ||
| if(found) return found_path; | ||
|
|
||
| // try the path of the packaged resource folder | ||
| dev_t volume = dev_for_path("/boot"); | ||
| char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH] = {}; | ||
| find_directory(B_SYSTEM_DATA_DIRECTORY, volume, false, buffer, sizeof(buffer)); | ||
| strcat(buffer, "/abaddon/"); | ||
|
|
||
| // check if the directory exists | ||
| BEntry entry(buffer); | ||
| if(entry.Exists() && entry.IsDirectory()) { | ||
| found = true; | ||
| found_path = std::string(buffer); | ||
| return found_path; | ||
| } | ||
|
|
||
| // otherwise, fall back to the cwd | ||
| spdlog::get("discord")->warn("cant find a resources folder, will try to load from cwd"); | ||
| found_path = "."; | ||
| found = true; | ||
| return found_path; | ||
| } | ||
|
|
||
| std::string Platform::FindConfigFile() { | ||
| const auto cfg = std::getenv("ABADDON_CONFIG"); | ||
| if (cfg != nullptr) return cfg; | ||
|
|
||
| static std::string found_path; | ||
| static bool found = false; | ||
| if (found) return found_path; | ||
|
|
||
| // generate the path of the config directory. If it does not exist, create it | ||
| dev_t volume = dev_for_path("/boot"); | ||
| char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH] = {}; | ||
| find_directory(B_USER_SETTINGS_DIRECTORY, volume, false, buffer, sizeof(buffer)); | ||
| strcat(buffer, "/abaddon/"); | ||
| create_directory(buffer, 0777); | ||
|
|
||
| strcat(buffer, "abaddon.ini"); | ||
| found_path = std::string(buffer); | ||
| return found_path; | ||
| } | ||
|
|
||
| std::string Platform::FindStateCacheFolder() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesnt create the directory
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've also moved the cache to the user directory instead of the system directory (in practice, Haiku is a single-user system, so it should not matter, but the cache cotains user-specific data) |
||
| static std::string found_path; | ||
| static bool found = false; | ||
| if (found) return found_path; | ||
|
|
||
| dev_t volume = dev_for_path("/boot"); | ||
| char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH]; | ||
| find_directory(B_USER_CACHE_DIRECTORY, volume, false, buffer, sizeof(buffer)); | ||
| strcat(buffer, "/abaddon/"); | ||
| create_directory(buffer, 0777); | ||
|
|
||
|
|
||
| found_path = std::string(buffer); | ||
| found = true; | ||
| return found_path; | ||
| } | ||
|
|
||
|
|
||
| #else | ||
| std::string Platform::FindResourceFolder() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you never set this to true