Saving worldfiles should not change relative path

Posted by Poromenos on Mon 26 Apr 2004 10:26 AM — 20 posts, 70,204 views.

Greece #0
I would like to keep my world/plugin/state files synchronized between my laptop and my desktop PC, but each copy of MUclient runs on different drive letters. I change all the pathnames to relative and it works fine, until I save a world file, in which case MUclient writes back all paths as absolute and messes everything up... Could it be changed so that it would write the pathnames as it read them?
Greece #1
Well, as it turns out, relative paths do not work fine...
auto_log_file_name="..\logs\Poromenos log.txt"
gives me an error saying it can't open the file... Can you also change MUclient to recognize paths?
Can I set something like an XML entity or whatever on top, so that I can only change that whenever I copy the files? That would be tedious however, with 50 world files... Maybe MUclient could have an internal variable like &MUclientPath; we could use in the filenames? What of these would be easier to implement?
USA #2
Most programs will use their own execution path as the 'base' for all operations. This works well, as long as all the links to run the program are pointing to that directory. Unfortunately if you ever look at a link file, you will notice the line "Start in:", if this is blank, then the execution path becomes what ever the link was located in. If this path points some place other than "C:\Program Files\MUSHclient", then again, same problem. I think there is some other way to determine it, but unfortunately a lot of programs rely on the OS to tell them where they started and thus what the 'default' path should be. Having MUSHclient figure out where it actually is 'should' be easier than having to edit even one setting, but how to *correctly* manage it I am uncertain of.
USA #3
Mushclient has some default paths in the registry file.

You could retrieve those, but that seems like an extreme workaround. I dont think itd be too hard to have MC supply us with some sort of default path (or all of them). A function with an arguement for which path you want (plugin, etc).

this would also help with distributed plugins, I know *I* never install into program files. But a lot of people do. So I need to have my plugins changed whenever I give them to someone else and theres file manipulation involved.

Then again, I suppose you could use an entity. Except like Poromenos said, if you have a lot of them, it seems like itd get tedious.
Greece #4
True, Shadowfyr, but I'm not suggesting that MUclient should use relative paths, I'm just suggesting that it shouldn't change them back to absolute when a user messes with them... Can I import an xml file that defines entities, or is that impossible? Come to think of it, MUclient will probably write the absolute paths again though :/
USA #5
I would think including something with entities should work, and it wouldnt overwrite, as Itd be an include.

Just declare a path entity, and then use that as your surrogate absolute path.
Greece #6
I think it would overwrite, since MUclient would read it correctly, but when it wrote it back, it wouldn't use the entity, it would just write the path...
Australia Forum Administrator #7
I have changed it to remove the absolute pathname when saving plugin names (in the world file) if it happens to start with the default plugins pathname.
Greece #8
Does it work properly with relative paths though? I tried it and a few worked, a few didn't... Could you test it please?
Greece #9
Ah, you released it, good :) I'll test it myself then, thanks :)
Greece #10
It works, but only for plugins, which leaves everything else with absolute pathnames :/ For example:
<include name="I:\Program Files\MUSHclient\worlds\include.xml" />
auto_log_file_name="I:\Program Files\MUSHclient\logs\Poromenos log.txt"
chat_file_save_directory="I:\Downloads"
script_filename="I:\Program Files\MUSHclient\WORLDS\Poromenos.vbs"
sound="E:\WINDOWS\Media\Page.wav"

Is there any way to make MUclient save the paths the way it found them if there is no problem in loading them?
Greece #11
The plugins work fine when transferred, but the rest of the files give errors...
Australia Forum Administrator #12
Yes, I only changed plugins. There is no default "include file path", so it was harder to do the "remove the default path" trick.

Greece #13
It doesn't actually have to remove the default paths for every file, that wouldn't work either... It just has to save the filenames back the way it found them. Hopefully that will work.
Australia Forum Administrator #14
Well, when you add a plugin using the plugin dialog you don't specify a relative path, you use the file browser dialog box which gives me an absolute path. So, I don't have a relative path to begin with.

However I tend to agree that it should save the file name it was actually given, if you happen to put a relative path in manually.
Greece #15
Yes, I agree with that. People don't generally need relative filepaths and MUclient shouldn't default to them, unless they edit it manually, in which case it should try to keep the path the user gave it...
Australia Forum Administrator #16
Version 3.50 now saves to the world file the exact name you gave, for an <include name="blah.xml" /> directive (however plugins still work as described earlier), so it should be easier for you to swap your world files around now.
Greece #17
Ah great, is it going to be released soon? I need that feature quite badly :p
Australia Forum Administrator #18
Trying to bump up your posts count with two almost identical replies? :)

As soon as I track down a couple more bugs, yes. Probably today. See forum subjects:

http://www.gammon.com.au/forum/?bbsubject_id=4166

and

http://www.gammon.com.au/forum/?bbsubject_id=4152

Once I track them down I will do a new release.
Greece #19
Err sorry, I think i hit escape while it was submitting the form and edited that one :P I'll delete the first one.