News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

[patch] load pak-files from subdirectories

Started by gerw, April 14, 2009, 09:06:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gerw

The request was posted by VS (http://forum.simutrans.com/index.php?topic=1557.msg19729#msg19729).

The _MSC_VER version is fully untested ;)

Patch can be found in a later post.

VS


My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Frank

load pak files from subdirectory

Waht is compatibility folder from pak128? Old pak files load all then?

VS

Good catch. I think there should be a safeguard against browsing folder - probably some file like nofollow.txt so that people can create it easily.

That is, skip folders that have this file in them.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

z9999

Is the way that folder name start with "~" => ignore insufficient ?
This way is used with many software like Photoshop to read extension.

VS


My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

gerw

#6
Now, folders starting with '~' are ignored. Can anyone test the _MSC_VER version?

VS

Around 17:00 I'll be back and test that.

Thanks a lot!

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

whoami

Quote from: gerw on April 15, 2009, 09:13:35 AM
Now, folders starting with '~' are ignored.
This character can have a special meaning (in bash, it has).
Instead, I suggest to not include subdirectories by default, but allow them to be configured in simuconf.tab (both pak and user location), with relative and absolute path.

VS

#9
gerw - sorry, it does not work. I'll test some more.

whoami - Allow me to disagree with your suggestion (config file). In my view, that defeats the whole beauty of "just add another folder and it still works". Including configuration in folder name avoids many problems and is a very simple rule.

I looked at bash documents and ~ appears a) in operator and b) for variable expansion in paths - which means problems only when in console, not for actual folders already existing on disk. Would another character instead of ~ work? Which one, then? It seems pretty much anything sane that can be typed casually (~@$!) is already some operator in bash :-\ That's not to say this is something to simply forget - your point about compatibility is important!

Note: I have zero problems using ~ in commands.

vladimir@hroch:~$ ls
aaa  Dokumenty  Examples  Plocha  simu_code  simu_128  simu_64  Šablony  Veřejné
vladimir@hroch:~$ mv aaa  ~aaa
vladimir@hroch:~$ ls
~aaa Dokumenty  Examples  Plocha  simu_code  simu_128  simu_64  Šablony  Veřejné
vladimir@hroch:~$ mv  ~aaa aaa
vladimir@hroch:~$ ls
aaa  Dokumenty  Examples  Plocha  simu_code  simu_128  simu_64  Šablony  Veřejné
vladimir@hroch:~$ rename
Usage: rename [-v] [-n] [-f] perlexpr [filenames]
vladimir@hroch:~$ rename s/aaa/~aaa/ aaa
vladimir@hroch:~$ ls
~aaa  Dokumenty  Examples  Plocha  simu_code  simu_128  simu_64  Šablony  Veřejné
vladimir@hroch:~$ cd /tmp/
vladimir@hroch:/tmp$ mkdir aaa
vladimir@hroch:/tmp$ ls
aaa             orbit-vladimir  seahorse-NLim2K        virtual-vladimir.zDJF7E
keyring-KR3yK6  pulse-vladimir  Tracker-vladimir.4994
vladimir@hroch:/tmp$ mv aaa ~aaa
vladimir@hroch:/tmp$ ls
~aaa            orbit-vladimir  seahorse-NLim2K        virtual-vladimir.zDJF7E
keyring-KR3yK6  pulse-vladimir  Tracker-vladimir.4994
vladimir@hroch:/tmp$ mv ~aaa abc
vladimir@hroch:/tmp$ ls
abc             orbit-vladimir  seahorse-NLim2K        virtual-vladimir.zDJF7E
keyring-KR3yK6  pulse-vladimir  Tracker-vladimir.4994
vladimir@hroch:/tmp$

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Michael 'Cruzer'

#10
It's seems not to work at MS Windows.
(Compiled with .NET-Framework)

Is there anything special to do? Like set a parameter in simuconf.tab, or anything else?
I only have created a subfolder in the pak-directory an add some paks.
Founder and Ex-Maintainer of pak192.comic. Provider of Simutrans Hosting rental service.

gerw

#11
Maybe the '_' is a good choice.

@_MSC_VER: Can somebody, who compiles with Windows, have a look at this patch?

@VS: Maybe you will have some trouble with "rm ~vladimir". Don't try this at home! The '~vladimir' will expand to your home directory.

Edit: New patch file. Now it skips folders starting with '_'.

VS

#12
I have only a virtual machine, so thanks for concern, but I do know what I am playing with :)

By the way, I am on windows...

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Isaac Eiland-Hall

well, for testing, one might test with 'ls' rather than 'rm' for dangerous commands... lol

Also, '_' seems like a good character. It's a pity that Windows doesn't allow filenames beginning with a period, because that would be a good natural possibility. :)

gerw

A new try of mine without nested findfirst, findnext. But it also doesn't work. Can someone with a Visual C compiler make it work?

VS

#15
I will... try ;D

update: it does not even compile.

Am I supposed to work only on part ifdefed for _MSC_VER and nothing outside that?

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

prissi

Actually it is planned to have all addons in ~simutrans/pak64 tho seperate it. I am not too keen on subdirectories, since this breaks a lot of the assumption where translations or sounds are and so on.

I fail to see the advantage of subdirectories a bit.

Zeno

Well, you can put paks wherever you want inside simutrans/pak64, let's say some addons in a folder called simutrans/pak64/addons, and some german style cool addons in simutrans/pak64/german_addons :)
You can now move/copy/add/delete/list/count/whatever them without getting mad in searching all pak files in the main pak folder. Of course there's no advantage at all if you don't want to mess up inside there.
Btw, what has that to do with translations? Are they related to the pak file path? Sounds are, no doubt, but can't they be addressed by the main folder? e.g. /simutrans/sounds, or whatever folder it is...

VS

Prissi, that is probably question of taste. I fail to see advantage of thousands of paks in one folder. And all other files are where they are, no? Not everything has to be subfolderized, only the data that come in bulk.

I don't think this is important enough to argue - do as you want :) In the end, it would be only a convenience for some cases. The biggest issue for users are addons, and your plan for them is more logical regardless of outcome of this.




gerw: Got it! You patched only the class but actual call with recursion switched on was left out.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

prissi

No I was to seperate paks and addon folder. I would put the addons into the personal folder. Thus you can replace your pak64 as often you like (and for network games make sure, that there are no other objects).

gerw

@VS:
Ok, I missed the changes in besch/reader/obj_reader.cc. I've done only a "svn diff utils/search_folder.*", since I patched it in a directory, where I also have an other patch applied. Can you post the patch, which is working with MSVC?

@prissi: I think it is useful, to have some more structure in the pak* folders. However, if you place the addons in ~/simutrans/pak*, you have to search all subdirectories there, otherwise the addon directory will mess up.

VS

#21
prissi: I understand (and understood before, too) :)

gerw: I got it to compile, found why it does not load and then saw it is not accepted. That's where I stopped. I still don't know whether it actually works, only that it compiles, runs and at least loads paks as before.




edit #1: The msvc version of code has some serious logic issues :-/ sprintf(buf, "%s/" buf) seems like a gross copy-paste error.




edit #2: Recursion works all right, but I can't get the cleanup to work.

edit #3: note to self, don't forget to allocate the one byte for trailing zero when working with that not-so-favourite language!




edit #4: So now the msvc version finally works all right. I do have doubts about the *nix version though, it still has that sprintf(fullname, "%s/" fullname) in it.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

gerw

Thank you!

About sprints: It works, but of course, strcat is more suitable for this case. I missed also one byte for the "/" ;)

This patch should work on all platforms.

VS

Thanks!

One minor remark - it doesn't loop in ..././././././... for you? At least on windows, . and .. are regular entries in folder listing. I had enough of that in past, so the stop on [0 ]=="." was reflex, not tested at all...

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

gerw


VS

#25
Good... so, it's probably done!

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!