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

26
LINES

< > BotCompany Repo | #1024959 // tarInJar_withMD5_withPredicate - repacks a .jar file, puts all files in bulk-{md5}.tar [dev.]

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (2527L) is out of date.

// predicate: func(S entry) -> bool (yes = should put in tar)
svoid tarInJar_withMD5_withPredicate(File jarIn, File jarOut, IF1<S, Bool> putInTar) ctex {
  IF1<S, Bool> dontPutInTar = name -> !putInTar.get(name);
  
  temp ZipOutputStream zipOut = zipOutputStream(jarOut);
  zip2zip_withPredicate(jarIn, zipOut, dontPutInTar);
  
  print("tarInJar_withMD5 " + f2s(jarIn) + " => " + f2s(jarOut));
  File tar = createTempFile("", ".tar");
  print("  temp: " + f2s(tar));
  temp tempDeleteFile(tar);
  
  zip2tar_withPredicate(jarIn, tar, putInTar);
  file2zip(zipOut, tar, "bulk-" + md5(tar) + ".tar");
}

svoid tarInJar_withMD5_withPredicate(File jarIn, IF1<S, Bool> predicate) {
  if (!fileExists(jarIn)) ret;
  File jarOut = fileInSameDirectory(jarIn, dropSuffixIC(".jar", jarIn.getName()) + ".repacked.jar");
  renameFileToUniqueName(jarOut); // backup old version
  tarInJar_withMD5_withPredicate(jarIn, jarOut, predicate);
}

svoid tarInJar_withMD5_withPredicate(S jarIn, IF1<S, Bool> predicate) {
  tarInJar_withMD5_withPredicate(newFile(jarIn), predicate);
}

Author comment

Began life as a copy of #1024956

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: #1024959
Snippet name: tarInJar_withMD5_withPredicate - repacks a .jar file, puts all files in bulk-{md5}.tar [dev.]
Eternal ID of this version: #1024959/3
Text MD5: af8ab194ef27bba827649cf314a227c0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-31 16:38:24
Source code size: 1089 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 109 / 177
Version history: 2 change(s)
Referenced in: [show references]