widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #02782
[Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
SirVer has proposed merging lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1342228 in widelands: "Widelands searches system paths for its data files by default."
https://bugs.launchpad.net/widelands/+bug/1342228
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/fix_setup_searchpaths/+merge/236410
Fixes the rest of the wrong searchpaths for Widelands.
--
https://code.launchpad.net/~widelands-dev/widelands/fix_setup_searchpaths/+merge/236410
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands.
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2014-09-18 18:46:22 +0000
+++ src/wlapplication.cc 2014-09-29 19:17:29 +0000
@@ -110,96 +110,6 @@
} // namespace
-/**
- * Sets the filelocators default searchpaths (partly OS specific)
- */
-// TODO(unknown): Handle exception FileTypeError
-// TODO(unknown): Handle case when \e no data can be found
-void WLApplication::setup_searchpaths(std::string argv0)
-{
- try {
-#if defined (__APPLE__) || defined(_WIN32)
- // on mac and windows, the default data dir is relative to the executable directory
- std::string s = get_executable_path();
- log("Adding executable directory to search path\n");
- g_fs->AddFileSystem(&FileSystem::Create(s));
-#else
- log ("Adding directory:%s\n", INSTALL_PREFIX "/" INSTALL_DATADIR);
- g_fs->AddFileSystem // see config.h
- (&FileSystem::Create
- (std::string(INSTALL_PREFIX) + '/' + INSTALL_DATADIR));
-#endif
- }
- catch (FileNotFoundError &) {}
- catch (FileAccessDeniedError & e) {
- log("Access denied on %s. Continuing.\n", e.m_filename.c_str());
- }
- catch (FileTypeError &) {
- //TODO(unknown): handle me
- }
-
- try {
-#ifdef __linux__
- // if that fails, search in FHS standard location (obviously UNIX-only)
- log ("Adding directory:/usr/share/games/widelands\n");
- g_fs->AddFileSystem(&FileSystem::Create("/usr/share/games/widelands"));
-#endif
- }
- catch (FileNotFoundError &) {}
- catch (FileAccessDeniedError & e) {
- log("Access denied on %s. Continuing.\n", e.m_filename.c_str());
- }
- catch (FileTypeError &) {
- //TODO(unknown): handle me
- }
-
- try {
-#ifndef __APPLE__
- /*
- * Why? Please do NOT attempt do read from random places.
- * absolute fallback directory is the CWD
- */
- log ("Adding directory:.\n");
- g_fs->AddFileSystem(&FileSystem::Create("."));
-#endif
- }
- catch (FileNotFoundError &) {}
- catch (FileAccessDeniedError & e) {
- log("Access denied on %s. Continuing.\n", e.m_filename.c_str());
- }
- catch (FileTypeError &) {
- //TODO(unknown): handle me
- }
-
- //TODO(unknown): what if all the searching failed? Bail out!
-
- // the directory the executable is in is the default game data directory
- std::string::size_type slash = argv0.rfind('/');
- std::string::size_type backslash = argv0.rfind('\\');
-
- if
- (backslash != std::string::npos &&
- (slash == std::string::npos || backslash > slash))
- slash = backslash;
-
- if (slash != std::string::npos) {
- argv0.erase(slash);
- if (argv0 != ".") {
- try {
- log ("Adding directory: %s\n", argv0.c_str());
- g_fs->AddFileSystem(&FileSystem::Create(argv0));
- }
- catch (FileNotFoundError &) {}
- catch (FileAccessDeniedError & e) {
- log ("Access denied on %s. Continuing.\n", e.m_filename.c_str());
- }
- catch (FileTypeError &) {
- //TODO(unknown): handle me
- }
- }
- }
-}
-
void WLApplication::setup_homedir() {
//If we don't have a home directory don't do anything
if (m_homedir.size()) {
@@ -263,7 +173,7 @@
m_mouse_locked (0),
m_mouse_compensate_warp(0, 0),
m_should_die (false),
-m_default_datadirs (true),
+m_use_default_datadir (true),
#ifdef _WIN32
m_homedir(FileSystem::GetHomedir() + "\\.widelands"),
#else
@@ -288,8 +198,13 @@
setup_homedir();
init_settings();
- if (m_default_datadirs)
- setup_searchpaths(m_commandline["EXENAME"]);
+
+ if (m_use_default_datadir) {
+ const std::string default_datadir =
+ std::string(INSTALL_PREFIX) + "/" + std::string(INSTALL_DATADIR);
+ log("Adding directory: %s\n", default_datadir.c_str());
+ g_fs->AddFileSystem(&FileSystem::Create(default_datadir));
+ }
init_language(); // search paths must already be set up
cleanup_replays();
@@ -1070,7 +985,7 @@
if (m_commandline.count("datadir")) {
log ("Adding directory: %s\n", m_commandline["datadir"].c_str());
g_fs->AddFileSystem(&FileSystem::Create(m_commandline["datadir"]));
- m_default_datadirs = false;
+ m_use_default_datadir = false;
m_commandline.erase("datadir");
}
=== modified file 'src/wlapplication.h'
--- src/wlapplication.h 2014-09-18 18:46:22 +0000
+++ src/wlapplication.h 2014-09-29 19:17:29 +0000
@@ -202,7 +202,6 @@
void parse_commandline(int argc, char const * const * argv);
void handle_commandline_parameters();
- void setup_searchpaths(std::string argv0);
void setup_homedir();
void cleanup_replays();
@@ -210,9 +209,7 @@
bool redirect_output(std::string path = "");
/**
- * The commandline, conveniently repackaged
- * This is usually not empty, it contains at least the tuple
- * {"EXENAME", argv0}
+ * The commandline, conveniently repackaged.
*/
std::map<std::string, std::string> m_commandline;
@@ -249,7 +246,7 @@
bool m_should_die;
//do we want to search the default places for widelands installs
- bool m_default_datadirs;
+ bool m_use_default_datadir;
std::string m_homedir;
/// flag indicating if stdout and stderr have been redirected
Follow ups
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: Hans Joachim Desserud, 2014-10-04
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: SirVer, 2014-10-04
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: Hans Joachim Desserud, 2014-10-04
-
[Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: noreply, 2014-10-04
-
[Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: GunChleoc, 2014-10-04
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: SirVer, 2014-10-04
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: GunChleoc, 2014-10-04
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: GunChleoc, 2014-10-04
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: GunChleoc, 2014-09-30
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: SirVer, 2014-09-30
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: GunChleoc, 2014-09-29
-
Re: [Merge] lp:~widelands-dev/widelands/fix_setup_searchpaths into lp:widelands
From: SirVer, 2014-09-29