bjornbytes / cargo

LÖVE asset manager
MIT License
163 stars 11 forks source link

Loader per directory, not just per file #15

Open coz-eduardo-hernandez opened 1 year ago

coz-eduardo-hernandez commented 1 year ago

Would it be possible to run/add a loader function that gets all files in a directory as an argument, instead of one loader function per file? My use case is loading multiple .pngs and putting them inside an ArrayImage.

bjornbytes commented 1 year ago

How should the key in the loaders table be formatted? Maybe some kind of special character/glob? Or maybe the directory could have an extension

coz-eduardo-hernandez commented 1 year ago

In both POSIX, Windows, removable media and modern Macs '/' forward slash is not allowed. In HFS, Mac's old filesystem with no write support since 2009 and no read support since 2019 it is allowed, and commonly used in dates, but I guess ( I've never owned a Mac ) it would be rare to find it in file extensions. So forward slash could be used, but you'd disallow forward slashes in file extensions in old Macs. They may also be used in filesystems I'm not aware of.

Alternatively, making the loader keys switch to Lua patterns instead of extensions would not have that restriction, but it would take away from the simplicity of the library.

I'd prefer the first option, but it's your call.