Libraryless. Click here for Pure Java version (5046L/28K).
1 | import java.util.jar.*; |
2 | |
3 | static LS classNamesInJarOrDir(File dir, S prefixInJar default "") {
|
4 | new LS classes; |
5 | if (dir == null) {}
|
6 | else if (dir.isDirectory()) {
|
7 | for (File f : listFiles(dir)) { // TODO: subdirectories
|
8 | S s = f.getName(); |
9 | if (s.endsWith(".class"))
|
10 | classes.add(dropSuffix(".class", s));
|
11 | } |
12 | } else if (dir.isFile()) pcall {
|
13 | JarFile jarFile = new JarFile(dir); |
14 | try {
|
15 | Enumeration<JarEntry> e = jarFile.entries(); |
16 | while (e.hasMoreElements()) {
|
17 | JarEntry je = e.nextElement(); |
18 | if (je.isDirectory() |
19 | || je.getName().startsWith("META-INF/")
|
20 | || !je.getName().endsWith(".class"))
|
21 | continue; |
22 | S className = dropSuffix(".class", je.getName());
|
23 | className = dropPrefixOrNull(prefixInJar, className); |
24 | if (className == null) continue; |
25 | if (className.contains("-")) continue;
|
26 | className = className.replace('/', '.');
|
27 | classes.add(className); |
28 | } |
29 | } finally {
|
30 | jarFile.close(); |
31 | } |
32 | } |
33 | ret classes; |
34 | } |
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: | 842 / 1023 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |