1 | sbool zipFileSnippetToLazyTextMap_subfolder_debug; |
2 | |
3 | // keeps file open until you cleanUp() the map |
4 | static SS zipFileSnippetToLazyTextMap_subfolder(S snippetID, S folderName) ctex { |
5 | if (empty(folderName)) ret zipFileSnippetToLazyTextMap(snippetID); |
6 | fS prefix = addSlash(folderName); |
7 | final ZipFile zip = new ZipFile(loadLibrary(snippetID)); |
8 | O f = func(S name) { |
9 | if (zipFileSnippetToLazyTextMap_subfolder_debug) |
10 | print("subfolder get " + prefix+name); |
11 | ret loadTextFileFromZipFile(zip, prefix + name); |
12 | }; |
13 | ret autoCleanUp(new LazyValueTreeMap(startingWith_dropPrefix(listFilesInZip(zip), prefix), f) { |
14 | public void finalize() ctex { |
15 | cleanMeUp(); |
16 | } |
17 | |
18 | void cleanMeUp() { |
19 | if (zipFileSnippetToLazyTextMap_subfolder_debug) |
20 | print("subfolder cleanup"); |
21 | pcall-silent { zip.close(); } |
22 | } |
23 | }); |
24 | } |
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: | 517 / 562 |
Version history: | 7 change(s) |
Referenced in: | [show references] |