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

44
LINES

< > BotCompany Repo | #1024921 // Archive Contents

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (3111L/16K).

!7

sclass Entry {
  S name;
  long size, compressedSize;
  
  sS _fieldOrder = "name size compressedSize";
}

cmodule ArchiveContents > DynObjectTable<Entry> {
  File archive;
  
  start {
    itemToMap = func(Entry e) -> Map { litorderedmap(
      "Name" := e.name,
      "Size" := formatInt(e.size, 14),
      "Compressed size" := formatInt(e.compressedSize, 14),
    ) };
  }
  
  visual withComputing(r {
    // setting sorters only sometimes work (second time?)
    addRowSorter(table());
    rowSorter_setComparators(table(), 1, alphaNumComparator(), 2, alphaNumComparator());
  },
    withCenteredButtons(super, "Load archive...", rThread loadArchive));
  
  void loadArchive enter {
    loadArchive(showFileChooser());
  }
  
  // API
  
  void loadArchive(File f) {
    setField(archive := f);
    setModuleName(joinNempties(": ", "Archive contents", f2s(f)));
    setData(map(listZipEntries(f), e ->
      nu Entry(
        name := e.getName(),
        size := e.getSize(),
        compressedSize := e.getCompressedSize()
      )));
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024921
Snippet name: Archive Contents
Eternal ID of this version: #1024921/13
Text MD5: 28033c61582fd7e137c0c29d3c215043
Transpilation MD5: 18a7437420e8b9f0d6e440548ad75443
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-30 12:26:50
Source code size: 1092 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 234 / 402
Version history: 12 change(s)
Referenced in: [show references]