Norbyte / ositools

Advanced scripting and mod support for Divinity Original Sin 2
MIT License
373 stars 30 forks source link

Expand Ext.IO #130

Open PinewoodPip opened 1 year ago

PinewoodPip commented 1 year ago

This PR adds various new functions to Ext.IO as well as a fix to an issue in its SaveFile() function. The new functions support GameStorage paths only.

Enumerate()

ObjectSet<FixedString> Enumerate(std::optional<STDString> path) Lists the directories and files relative to the path. If path is not provided, it defaults to the root of Osiris Data (equivalent to passing an empty string). If the path is invalid, returns an empty list. image

IsFile() & IsDirectory()

bool IsFile(char const* path) bool IsDirectory(char const* path) Returns whether the path passed is a regular file or directory, respectively. Returns false in the case of invalid/non-existent paths. image

SaveFile() fix

This PR fixes not being able to save a file with SaveFile() if it involved creating more than one directory along the path. For example, Ext.IO.SaveFile("A/B/MyFile.json") would previously fail if directory A didn't exist as CreateDirectoryW() can only create at most one directory.