-
Notifications
You must be signed in to change notification settings - Fork 186
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
Use %appdata% on windows. #1437
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 |
---|---|---|
|
@@ -107,10 +107,11 @@ int main(int argc, char** argv) | |
#ifdef CONFIG_DIR | ||
PreferencesManager::load(CONFIG_DIR "options.ini"); | ||
#endif | ||
PreferencesManager::load("options.ini"); | ||
if (getenv("HOME")) | ||
PreferencesManager::load(string(getenv("HOME")) + "/.emptyepsilon/options.ini"); | ||
else | ||
PreferencesManager::load("options.ini"); | ||
if (getenv("APPDATA")) | ||
PreferencesManager::load(string(getenv("APPDATA")) + "/emptyepsilon/options.ini"); | ||
|
||
for(int n=1; n<argc; n++) | ||
{ | ||
|
@@ -153,6 +154,11 @@ int main(int argc, char** argv) | |
new DirectoryResourceProvider(string(getenv("HOME")) + "/.emptyepsilon/resources/mods/" + mod); | ||
PackResourceProvider::addPackResourcesForDirectory(string(getenv("HOME")) + "/.emptyepsilon/resources/mods/" + mod); | ||
} | ||
if (getenv("APPDATA")) | ||
{ | ||
new DirectoryResourceProvider(string(getenv("APPDATA")) + "/emptyepsilon/resources/mods/" + mod); | ||
PackResourceProvider::addPackResourcesForDirectory(string(getenv("APPDATA")) + "/emptyepsilon/resources/mods/" + mod); | ||
} | ||
new DirectoryResourceProvider("resources/mods/" + mod); | ||
PackResourceProvider::addPackResourcesForDirectory("resources/mods/" + mod); | ||
} | ||
|
@@ -167,6 +173,12 @@ int main(int argc, char** argv) | |
new DirectoryResourceProvider(string(getenv("HOME")) + "/.emptyepsilon/scripts/"); | ||
new DirectoryResourceProvider(string(getenv("HOME")) + "/.emptyepsilon/packs/SolCommand/"); | ||
} | ||
if (getenv("APPDATA")) | ||
{ | ||
new DirectoryResourceProvider(string(getenv("APPDATA")) + "/emptyepsilon/resources/"); | ||
new DirectoryResourceProvider(string(getenv("APPDATA")) + "/emptyepsilon/scripts/"); | ||
new DirectoryResourceProvider(string(getenv("APPDATA")) + "/emptyepsilon/packs/SolCommand/"); | ||
} | ||
#ifdef RESOURCE_BASE_DIR | ||
new DirectoryResourceProvider(RESOURCE_BASE_DIR "resources/"); | ||
new DirectoryResourceProvider(RESOURCE_BASE_DIR "scripts/"); | ||
|
@@ -306,10 +318,11 @@ int main(int argc, char** argv) | |
#ifdef CONFIG_DIR | ||
hardware_controller->loadConfiguration(CONFIG_DIR "hardware.ini"); | ||
#endif | ||
hardware_controller->loadConfiguration("hardware.ini"); | ||
if (getenv("HOME")) | ||
hardware_controller->loadConfiguration(string(getenv("HOME")) + "/.emptyepsilon/hardware.ini"); | ||
else | ||
hardware_controller->loadConfiguration("hardware.ini"); | ||
if (getenv("APPDATA")) | ||
hardware_controller->loadConfiguration(string(getenv("APPDATA")) + "/emptyepsilon/hardware.ini"); | ||
|
||
#if WITH_DISCORD | ||
{ | ||
|
@@ -353,7 +366,6 @@ int main(int argc, char** argv) | |
if (PreferencesManager::get("headless") == "") | ||
{ | ||
#ifndef _MSC_VER | ||
// MFC TODO: Fix me -- save prefs to user prefs dir on Windows. | ||
if (getenv("HOME")) | ||
{ | ||
#ifdef _WIN32 | ||
|
@@ -362,6 +374,14 @@ int main(int argc, char** argv) | |
mkdir((string(getenv("HOME")) + "/.emptyepsilon").c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); | ||
#endif | ||
PreferencesManager::save(string(getenv("HOME")) + "/.emptyepsilon/options.ini"); | ||
}else if (getenv("APPDATA")) | ||
{ | ||
#ifdef _WIN32 | ||
mkdir((string(getenv("APPDATA")) + "/emptyepsilon").c_str()); | ||
#else | ||
mkdir((string(getenv("APPDATA")) + "/emptyepsilon").c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); | ||
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 feels like happy-go-lucky copypasta: which platform is this supposed to handle? I don't think APPDATA really is a thing to worry about on anything but windows :) 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. Yeah, copypasta is what it was. A more eloquent solution would be ideal. |
||
#endif | ||
PreferencesManager::save(string(getenv("APPDATA")) + "/emptyepsilon/options.ini"); | ||
}else | ||
#endif | ||
{ | ||
|
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.
Instead of additional branches, it would probably make more sense to swap
HOME
forAPPDATA
on windows.Better yet - store the result of
getenv(<home or appdata>)
once, and use that throughout.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.
Yeah, copypasta...
HOME
is also not a thing on Windows either... I just extended the current solution rather than re-implementing a better one.