aMule Forum

English => Feature requests => Topic started by: linuxfever on August 01, 2007, 10:24:31 PM

Title: portable on windows
Post by: linuxfever on August 01, 2007, 10:24:31 PM
I wish to set up where configuration is stored. Currently it`s in documents and settings folder. I would change it to ./ to make it work on usb harddisks too.
Title: Re: portable on windows
Post by: skolnick on August 02, 2007, 02:35:58 AM
Then modify aMule source code, and recompile it. Or try eMule.

Regards.
Title: Re: portable on windows
Post by: Kry on August 02, 2007, 03:20:17 AM
Well, we COULD do that. If anyone wants to code a preferences option for "use local config on execution folder" or similar.
Title: Re: portable on windows
Post by: wuischke on August 02, 2007, 08:40:52 AM
How do you think about a check for a local (writeable) config folder on startup to determine the location?
Title: Re: portable on windows
Post by: Kry on August 02, 2007, 04:40:26 PM
Naaaah. Only check first for a config in the folder where it's executed, and if it's not there, then the standard ones.
Title: Re: portable on windows
Post by: wuischke on August 02, 2007, 06:09:03 PM
OK, that's what I meant. Breaking the startup code would be a new experience for me anyway...;)

http://bugs.amule.org/view.php?id=1155
Title: Re: portable on windows
Post by: skolnick on August 03, 2007, 03:51:34 AM
Naaaah. Only check first for a config in the folder where it's executed, and if it's not there, then the standard ones.
Maybe check it in the reverse order? that way a user could override global configuration with a configuration in his $HOME folder.

Regards.
Title: Re: portable on windows
Post by: wuischke on August 03, 2007, 08:31:24 AM
I've written the code for Kry's variant (not commited+breaks coding standards) and current behaviour really surprised me.

I compiled it, created a 'config' dir in the current working directory and on startup aMule copied all files from ~/.aMule to this directory, because there was no amule.conf. Unintentionally I found a method to automatically convert a user config to a local config.

The downside? Have a 'config' folder in ~ (=cwd) and you might not even realize that aMule just converted to a new configuration directory. Even though this could be solved by a message, I have currently no way to suppress this behaviour if the user doesn't want to use ~/config , but needs this directory for whatever reason.

For those who want to play with it:
Code: [Select]
--- src/OtherFunctions.cpp (revision 7364)
+++ src/OtherFunctions.cpp (working copy)
@@ -1154,6 +1154,14 @@
 
 wxString GetConfigDir()
 {
+ wxString directory = wxGetCwd() + wxFileName::GetPathSeparator() + wxT("config") + wxFileName::GetPathSeparator();
+ if (wxDirExists(directory)) {
+ printf("Found local 'config' directory.\n");
+ if (not wxAccess(directory, R_OK | W_OK | X_OK)) {
+ return directory;
+ }
+ printf("Insufficient permissions on 'config', using user configuration folder.\n");
+ }
  return GetUserDataDir() + wxFileName::GetPathSeparator();
 }
Title: Re: portable on windows
Post by: wuischke on October 12, 2007, 01:19:12 PM
I implemented this feature now.

aMule will look for a configuration in ./config and will only use it if there's a file amule.conf in the config folder. An example:
Code: [Select]
This is your portable aMule directory structure:
./bin
./config
./temp
./incoming

When you start aMule with ./bin/amule and it will search for ./config/amule.conf, not ./bin/config/amule.conf i.e. the config directory is relative to the current working directory, not to the aMule executable.
I'm not sure whether relative paths are allowed for Temp and Incoming folders, this might have to be adjusted by an startup script.


Now: Anyone out there interested in creating a Portable aMule package? All you should need is a static aMule binary and a little startup script. Please contact me if there are any other lookup paths which have to be adjusted.