Libraryless. Click here for Pure Java version (5046L/28K).
import java.util.jar.*; static LS classNamesInJarOrDir(File dir, S prefixInJar default "") { new LS classes; if (dir == null) {} else if (dir.isDirectory()) { for (File f : listFiles(dir)) { // TODO: subdirectories S s = f.getName(); if (s.endsWith(".class")) classes.add(dropSuffix(".class", s)); } } else if (dir.isFile()) pcall { JarFile jarFile = new JarFile(dir); try { Enumeration<JarEntry> e = jarFile.entries(); while (e.hasMoreElements()) { JarEntry je = e.nextElement(); if (je.isDirectory() || je.getName().startsWith("META-INF/") || !je.getName().endsWith(".class")) continue; S className = dropSuffix(".class", je.getName()); className = dropPrefixOrNull(prefixInJar, className); if (className == null) continue; if (className.contains("-")) continue; className = className.replace('/', '.'); classes.add(className); } } finally { jarFile.close(); } } ret classes; }
Began life as a copy of #1006696
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008510 |
Snippet name: | classNamesInJarOrDir |
Eternal ID of this version: | #1008510/8 |
Text MD5: | 04831e379c8ce46621c860659e147b2a |
Transpilation MD5: | cd8f7c910fb47f99abe1cd56ad172bfc |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-29 06:23:53 |
Source code size: | 1087 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 564 / 678 |
Version history: | 7 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |