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.
Refresh VFS in "development mode"
Moderator: Moderators
Re: Refresh VFS in "development mode"
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)
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"
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.
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"
I can modify existing files, sure, but it doesn't detect new files until restart.
Re: Refresh VFS in "development mode"
Works for me! On step 2, I see the newly created file.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.
Re: Refresh VFS in "development mode"
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.
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"
Btw, I'm still having this issue. I really want to mark it solved, it's kinda annoying:
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.
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.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.
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.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Refresh VFS in "development mode"
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"
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.
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"
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.gajop wrote:I still need to restart Spring every time I add new files as part of the mod.
Re: Refresh VFS in "development mode"
It happens in both cases when using accessing stuff via VFS.MOD.abma wrote: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.gajop wrote:I still need to restart Spring every time I add new files as part of the 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.