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)

// keeps file open until you cleanUp() the map
static SS zipFileSnippetToLazyTextMap(S snippetID) ctex {
  final ZipFile zip = new ZipFile(loadLibrary(snippetID));
  O f = func(S name) { loadTextFileFromZipFile(zip, name) };
  ret autoCleanUp(new LazyValueTreeMap(listFilesInZip(zip), f) {
    public void finalize() ctex {
      cleanMeUp();
    }
    
    void cleanMeUp() {
      pcall-silent { zip.close(); }
    }
  });
}

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: 417 / 486
Version history: 12 change(s)
Referenced in: [show references]