sbool zipFileSnippetToLazyTextMap_subfolder_debug; // keeps file open until you cleanUp() the map static SS zipFileSnippetToLazyTextMap_subfolder(S snippetID, S folderName) ctex { if (empty(folderName)) ret zipFileSnippetToLazyTextMap(snippetID); fS prefix = addSlash(folderName); final ZipFile zip = new ZipFile(loadLibrary(snippetID)); O f = func(S name) { if (zipFileSnippetToLazyTextMap_subfolder_debug) print("subfolder get " + prefix+name); ret loadTextFileFromZipFile(zip, prefix + name); }; ret autoCleanUp(new LazyValueTreeMap(startingWith_dropPrefix(listFilesInZip(zip), prefix), f) { public void finalize() ctex { cleanMeUp(); } void cleanMeUp() { if (zipFileSnippetToLazyTextMap_subfolder_debug) print("subfolder cleanup"); pcall-silent { zip.close(); } } }); }
Began life as a copy of #1008856
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1008861 |
| Snippet name: | zipFileSnippetToLazyTextMap_subfolder - reads all file names instantly (keys), loads values lazily (file contents) |
| Eternal ID of this version: | #1008861/8 |
| Text MD5: | d1f2bcee5443f867dd5547b005a2b96c |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-04-01 04:30:26 |
| Source code size: | 872 bytes / 24 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 739 / 778 |
| Version history: | 7 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |