Page 1 of 1

Refresh VFS in "development mode"

Posted: 26 Oct 2012, 23:28
by gajop
Is there any way to refresh VFS so it becomes aware of any files that have been added/removed?
Often when working on new features, I gradually add new files, and it's cumbersome to have to restart spring every time, when something like /luaui reload or /luarules reload should be enough. Require me to put "devel = true" in modinfo.lua if needs be.

Re: Refresh VFS in "development mode"

Posted: 27 Oct 2012, 11:47
by gajop
This could also be useful outside of dev mode, for things like having an in-game load/save mechanism. Example of the scenario:
1) Person saves a game into a new file (this can be done using the built in os library)
2) Person wants to load a game, using VFS.DirList* to list existing files in a directory, one can only see old files, the new file wouldn't appear.

*VFS.DirList seems to be the only cross-platform way to list files in a directory in Spring, is there anything else? (the only libraries I found seem to require compiling, like f.e LFS)

Re: Refresh VFS in "development mode"

Posted: 27 Oct 2012, 14:38
by jK
The VFS has many `lenses` (to speak in unity terms). And the native fs lense, doesn't cache anything and always loads the current data.
So when your game files are in a .sdd, you can modify them at runtime. It's also the point of /luaxyz reload, /reloadcegs & /reloadcob.

Re: Refresh VFS in "development mode"

Posted: 27 Oct 2012, 15:37
by gajop
I can modify existing files, sure, but it doesn't detect new files until restart.

Re: Refresh VFS in "development mode"

Posted: 27 Oct 2012, 19:10
by zwzsg
gajop wrote:This could also be useful outside of dev mode, for things like having an in-game load/save mechanism. Example of the scenario:
1) Person saves a game into a new file (this can be done using the built in os library)
2) Person wants to load a game, using VFS.DirList* to list existing files in a directory, one can only see old files, the new file wouldn't appear.
Works for me! On step 2, I see the newly created file.

Re: Refresh VFS in "development mode"

Posted: 31 Oct 2012, 16:19
by gajop
Odd, works for me too.
I'm 100% sure that it didn't work with images (to be used in chili components), and it didn't work with VFS.Include.

Btw, let's say I want to implement a save/load mechanic (or something similar). I can load files using VFS.LoadFile, which maps files as seen in the VFS.DirList (lua doesn't implement it's own directory listing function, so I have to rely on this).
However, how am I supposed to save a file (a string)? Using io.open doesn't work here, as it uses the OS fs, not the VFS one (directories just don't look the same).
Basically, I'd like a VFS.SaveFile(filename, stringData) function, or something that maps VFS path to OS path.

Re: Refresh VFS in "development mode"

Posted: 21 Aug 2013, 00:56
by gajop
Btw, I'm still having this issue. I really want to mark it solved, it's kinda annoying:
Often when working on new features, I gradually add new files, and it's cumbersome to have to restart spring every time, when something like /luaui reload or /luarules reload should be enough. Require me to put "devel = true" in modinfo.lua if needs be.
Every time I add new lua files to my project I need to restart Spring, probably because how I include them, which is done by iterating through all paths of a VFS.DirList() and including them via VFS.Include(). Newly added files don't appear in VFS.DirList(), and they probably don't appear because I'm using VFS.DirList() without a VFS.RAW_ONLY param.

So VFS.DirList() can be used to get new files, but in order to do that VFS.RAW_ONLY must be used, even when working in an .sdd folder. Is this a bug or intended? Not a biggy for me, but it means I just need to use a prefix with "games/ToolBox.sdd", still seems off.

Re: Refresh VFS in "development mode"

Posted: 21 Aug 2013, 01:29
by Silentwings
At some point in the past there was /editdefs but i've not made it work for a while.

Re: Refresh VFS in "development mode"

Posted: 24 Jul 2014, 10:58
by gajop
So, uhm, bump!
I still need to restart Spring every time I add new files as part of the mod.
We really need a development mode that would allow files in VFS.MOD to be updated much like the VFS.RAW.

Re: Refresh VFS in "development mode"

Posted: 29 Sep 2014, 16:58
by abma
gajop wrote:I still need to restart Spring every time I add new files as part of the mod.
imo this makes sense, as archives are "synced". are you trying to access the files from synced or from unsynced? i guess to update file list at c++ side currently RemoveArchive + AddArchive has to be called at least.

Re: Refresh VFS in "development mode"

Posted: 29 Sep 2014, 23:05
by gajop
abma wrote:
gajop wrote:I still need to restart Spring every time I add new files as part of the mod.
imo this makes sense, as archives are "synced". are you trying to access the files from synced or from unsynced? i guess to update file list at c++ side currently RemoveArchive + AddArchive has to be called at least.
It happens in both cases when using accessing stuff via VFS.MOD.
While it's fine for .sdz, .sd7 and in the odd case when you are multiplayer testing an .sdd archive, I don't think it makes much sense for when you are developing. I find it analogous to restarting an IDE each time I add a file, which would be a bit annoying if you try to keep your code modular.