Is there a way to list folders and files in Krom? I'm targeting Krom and I need to be able to list the directories in a "Mods" folder and execute the krom.js
file in every mod. As far as I can tell, the Kha API allows you to load blobs from a path, but it doesn't allow you to list directories or files within a path. I suppose that makes a certain amount of sense because that wouldn't work on all platforms, such as web, but I do need a way to do it on the Krom platform.
-
Is There a Way to List Folders and Files in Krom?
-
Is There a Way to List Folders and Files in Krom?
@robert I just had an idea, would it be possible to compile the sys package from the Haxe standard library to C++ using the Haxe C++ backend, include this generated C++ code in Krom, and bind it to Javascript. That would allow us to avoid having to re-implement sys from scratch in Krom.
HashLink can also compile to C so that might be another option for sourcing the sys implementation.
Do you think this would work or would there be problems. I don't have experience in C/C++, but I'm wanting to get sys support in Krom so I thought that this might be an easy way to get a sys implementation without having to start from nothing.
-
Is There a Way to List Folders and Files in Krom?
There would be plenty of problems, Haxe-generated C++ or C can not simply be used like that because it depends on its own standard lib implementation and a garbage collector. It think starting from nothing would be easier - but most required functionality lingers somewhere in Kore or Krom already, a sys impl really isn't that much work and if nobody sends a pull request I'll get to it myself eventually.
-
Is There a Way to List Folders and Files in Krom?
You can already do this in Krom through the use of
Krom.sysCommand()
. You can then redirect the output of any command into a temp file and read it back in Krom.As an example zui has a file browser which works for Krom, tested on Windows/Linux/macOS:
https://github.com/armory3d/zui/blob/master/Sources/zui/Ext.hx#L115It's kind of a low-level solution, I have deployed it in ArmorPaint and so far it works reliably. Having a sys api would be the best of course, also happy to help on that.