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.

1  
// predicate: func(S entry) -> bool (yes = should put in tar)
2  
svoid tarInJar_withMD5_withPredicate(File jarIn, File jarOut, IF1<S, Bool> putInTar) ctex {
3  
  IF1<S, Bool> dontPutInTar = name -> !putInTar.get(name);
4  
  
5  
  temp ZipOutputStream zipOut = zipOutputStream(jarOut);
6  
  zip2zip_withPredicate(jarIn, zipOut, dontPutInTar);
7  
  
8  
  print("tarInJar_withMD5 " + f2s(jarIn) + " => " + f2s(jarOut));
9  
  File tar = createTempFile("", ".tar");
10  
  print("  temp: " + f2s(tar));
11  
  temp tempDeleteFile(tar);
12  
  
13  
  zip2tar_withPredicate(jarIn, tar, putInTar);
14  
  file2zip(zipOut, tar, "bulk-" + md5(tar) + ".tar");
15  
}
16  
17  
svoid tarInJar_withMD5_withPredicate(File jarIn, IF1<S, Bool> predicate) {
18  
  if (!fileExists(jarIn)) ret;
19  
  File jarOut = fileInSameDirectory(jarIn, dropSuffixIC(".jar", jarIn.getName()) + ".repacked.jar");
20  
  renameFileToUniqueName(jarOut); // backup old version
21  
  tarInJar_withMD5_withPredicate(jarIn, jarOut, predicate);
22  
}
23  
24  
svoid tarInJar_withMD5_withPredicate(S jarIn, IF1<S, Bool> predicate) {
25  
  tarInJar_withMD5_withPredicate(newFile(jarIn), predicate);
26  
}

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: 171 / 265
Version history: 2 change(s)
Referenced in: [show references]