Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1008856 // zipFileSnippetToLazyTextMap - reads all file names instantly (keys), loads values lazily (file contents)

JavaX fragment (include)

1  
// keeps file open until you cleanUp() the map
2  
static SS zipFileSnippetToLazyTextMap(S snippetID) ctex {
3  
  final ZipFile zip = new ZipFile(loadLibrary(snippetID));
4  
  O f = func(S name) { loadTextFileFromZipFile(zip, name) };
5  
  ret autoCleanUp(new LazyValueTreeMap(listFilesInZip(zip), f) {
6  
    public void finalize() ctex {
7  
      cleanMeUp();
8  
    }
9  
    
10  
    void cleanMeUp() {
11  
      pcall-silent { zip.close(); }
12  
    }
13  
  });
14  
}

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: #1008856
Snippet name: zipFileSnippetToLazyTextMap - reads all file names instantly (keys), loads values lazily (file contents)
Eternal ID of this version: #1008856/13
Text MD5: 1c119ea61f30ae05735e26bd5b5b13ed
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:44
Source code size: 439 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 492 / 561
Version history: 12 change(s)
Referenced in: [show references]