[patch] load pak-files from subdirectories April 14, 2009, 09:06:26 pm 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. Quote Selected Last Edit: April 15, 2009, 05:07:21 pm by gerw
Re: [patch] load pak-files from subdirectories Reply #1 – April 14, 2009, 09:30:49 pm Wow, that was fast Quote Selected
Re: [patch] load pak-files from subdirectories Reply #2 – April 15, 2009, 01:58:32 am load pak files from subdirectoryWaht is compatibility folder from pak128? Old pak files load all then? Quote Selected
Re: [patch] load pak-files from subdirectories Reply #3 – April 15, 2009, 07:31:49 am 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. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #4 – April 15, 2009, 08:07:32 am Is the way that folder name start with "~" => ignore insufficient ?This way is used with many software like Photoshop to read extension. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #5 – April 15, 2009, 08:30:32 am That is an option, too. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #6 – April 15, 2009, 09:13:35 am Now, folders starting with '~' are ignored. Can anyone test the _MSC_VER version? Quote Selected Last Edit: April 15, 2009, 05:06:44 pm by gerw
Re: [patch] load pak-files from subdirectories Reply #7 – April 15, 2009, 10:04:36 am Around 17:00 I'll be back and test that.Thanks a lot! Quote Selected
Re: [patch] load pak-files from subdirectories Reply #8 – April 15, 2009, 02:25:18 pm Quote from: gerw – on April 15, 2009, 09:13:35 amNow, 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. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #9 – April 15, 2009, 03:47:49 pm 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:~$ lsaaa Dokumenty Examples Plocha simu_code simu_128 simu_64 Šablony Veřejnévladimir@hroch:~$ mv aaa ~aaavladimir@hroch:~$ ls~aaa Dokumenty Examples Plocha simu_code simu_128 simu_64 Šablony Veřejnévladimir@hroch:~$ mv ~aaa aaavladimir@hroch:~$ lsaaa Dokumenty Examples Plocha simu_code simu_128 simu_64 Šablony Veřejnévladimir@hroch:~$ renameUsage: rename [-v] [-n] [-f] perlexpr [filenames]vladimir@hroch:~$ rename s/aaa/~aaa/ aaavladimir@hroch:~$ ls~aaa Dokumenty Examples Plocha simu_code simu_128 simu_64 Šablony Veřejnévladimir@hroch:~$ cd /tmp/vladimir@hroch:/tmp$ mkdir aaavladimir@hroch:/tmp$ lsaaa orbit-vladimir seahorse-NLim2K virtual-vladimir.zDJF7Ekeyring-KR3yK6 pulse-vladimir Tracker-vladimir.4994vladimir@hroch:/tmp$ mv aaa ~aaavladimir@hroch:/tmp$ ls~aaa orbit-vladimir seahorse-NLim2K virtual-vladimir.zDJF7Ekeyring-KR3yK6 pulse-vladimir Tracker-vladimir.4994vladimir@hroch:/tmp$ mv ~aaa abcvladimir@hroch:/tmp$ lsabc orbit-vladimir seahorse-NLim2K virtual-vladimir.zDJF7Ekeyring-KR3yK6 pulse-vladimir Tracker-vladimir.4994vladimir@hroch:/tmp$ Quote Selected Last Edit: April 15, 2009, 04:08:37 pm by VS
Re: [patch] load pak-files from subdirectories Reply #10 – April 15, 2009, 04:00:28 pm 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. Quote Selected Last Edit: April 15, 2009, 04:23:06 pm by Cruzer
Re: [patch] load pak-files from subdirectories Reply #11 – April 15, 2009, 04:47:35 pm 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 '_'. Quote Selected Last Edit: April 15, 2009, 05:06:26 pm by gerw
Re: [patch] load pak-files from subdirectories Reply #12 – April 15, 2009, 05:08:02 pm 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... Quote Selected Last Edit: April 15, 2009, 05:25:22 pm by VS
Re: [patch] load pak-files from subdirectories Reply #13 – April 15, 2009, 05:34:28 pm well, for testing, one might test with 'ls' rather than 'rm' for dangerous commands... lolAlso, '_' 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. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #14 – April 15, 2009, 07:01:37 pm 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? Quote Selected
Re: [patch] load pak-files from subdirectories Reply #15 – April 15, 2009, 07:29:29 pm I will... try update: it does not even compile.Am I supposed to work only on part ifdefed for _MSC_VER and nothing outside that? Quote Selected Last Edit: April 15, 2009, 08:45:29 pm by VS
Re: [patch] load pak-files from subdirectories Reply #16 – April 15, 2009, 08:46:41 pm 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 ****umption where translations or sounds are and so on.I fail to see the advantage of subdirectories a bit. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #17 – April 15, 2009, 08:58:28 pm 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... Quote Selected
Re: [patch] load pak-files from subdirectories Reply #18 – April 15, 2009, 09:08:25 pm 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 cl**** but actual call with recursion switched on was left out. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #19 – April 15, 2009, 09:40:13 pm 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). Quote Selected
Re: [patch] load pak-files from subdirectories Reply #20 – April 16, 2009, 07:54:12 am @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. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #21 – April 16, 2009, 10:07:44 am 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. Quote Selected Last Edit: April 17, 2009, 02:01:17 pm by VS
Re: [patch] load pak-files from subdirectories Reply #22 – April 17, 2009, 03:33:29 pm 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. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #23 – April 17, 2009, 03:41:11 pm 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... Quote Selected
Re: [patch] load pak-files from subdirectories Reply #24 – April 17, 2009, 03:49:02 pm This is blocked in line 128. Quote Selected
Re: [patch] load pak-files from subdirectories Reply #25 – April 17, 2009, 04:04:02 pm Good... so, it's probably done! Quote Selected Last Edit: April 17, 2009, 04:47:28 pm by VS