← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2210: Support for overriding automatic path configuration (thanks Razzloss)

 

------------------------------------------------------------
revno: 2210
fixes bug(s): https://launchpad.net/bugs/538478
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-08-12 22:13:16 -0500
message:
  Support for overriding automatic path configuration (thanks Razzloss)
modified:
  dcpp/Util.cpp
  dcpp/Util.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/Util.cpp'
--- dcpp/Util.cpp	2010-06-30 14:40:00 +0000
+++ dcpp/Util.cpp	2010-08-13 03:13:16 +0000
@@ -104,7 +104,7 @@
 
 #endif
 
-void Util::initialize() {
+void Util::initialize(PathsMap pathOverrides) {
 	Text::initialize();
 
 	sgenrand((unsigned long)time(NULL));
@@ -173,10 +173,8 @@
 	}
 
 	paths[PATH_USER_LOCAL] = paths[PATH_USER_CONFIG];
-
-	// @todo paths[PATH_RESOURCES] = <replace from sconscript?>;
-	// @todo paths[PATH_LOCALE] = <replace from sconscript?>;
-
+	paths[PATH_RESOURCES] = "/usr/share/";
+	paths[PATH_LOCALE] = paths[PATH_RESOURCES] + "locale/";
 	paths[PATH_DOWNLOADS] = home + "/Downloads/";
 #endif
 
@@ -184,6 +182,13 @@
 	paths[PATH_HUB_LISTS] = paths[PATH_USER_LOCAL] + "HubLists" PATH_SEPARATOR_STR;
 	paths[PATH_NOTEPAD] = paths[PATH_USER_CONFIG] + "Notepad.txt";
 
+	// Override core generated paths
+	for (PathsMap::const_iterator it = pathOverrides.begin(); it != pathOverrides.end(); ++it)
+	{
+		if (!it->second.empty())
+			paths[it->first] = it->second;
+	}
+
 	File::ensureDirectory(paths[PATH_USER_CONFIG]);
 	File::ensureDirectory(paths[PATH_USER_LOCAL]);
 

=== modified file 'dcpp/Util.h'
--- dcpp/Util.h	2010-06-30 14:40:00 +0000
+++ dcpp/Util.h	2010-08-13 03:13:16 +0000
@@ -118,7 +118,8 @@
 		PATH_LAST
 	};
 
-	static void initialize();
+	typedef std::map<Util::Paths, std::string> PathsMap;
+	static void initialize(PathsMap pathOverrides = PathsMap());
 
 	/** Path of temporary storage */
 	static string getTempPath() {