Libraryless. Click here for Pure Java version (6664L/45K).
static IResourceLoader resourceLoaderFromJar(File mainJar, File unpackDir) { print("Unpacking to: " + unpackDir); SS titles = cast safeUnstructure(loadTextFileFromZip(mainJar, "snippet-titles.struct")); assertNempty("Snippet titles", titles); Map<S, Int> types = cast safeUnstructure(loadTextFileFromZip(mainJar, "snippet-types.struct")); ret new IResourceLoader { public S loadSnippet(S snippetID) { ret loadTextFileFromZip(mainJar, psI(snippetID) + ".text"); } public S getTranspiled(S snippetID) { S src = loadTextFileFromZip(mainJar, psI(snippetID) + ".transpiled"); if (empty(src)) print("Warning: Transpilation for " + snippetID + " not found"); ret src; } public int getSnippetType(S snippetID) { ret or0(types.get(fsI(snippetID))); } public S getSnippetTitle(S snippetID) { ret titles.get(fsI(snippetID)); } public File loadLibrary(S snippetID) { long id = psI(snippetID); if (isImageServerSnippet(id)) ret optExtractFileFromZipToDir_tryMultipleNames(mainJar, unpackDir, id + ".png", id + ".gif"); else ret optExtractFileFromZipToDir(mainJar, unpackDir, id + ".bin"); } public File pathToJavaXJar() { ret mainJar; } }; }
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1022668 |
Snippet name: | resourceLoaderFromJar |
Eternal ID of this version: | #1022668/6 |
Text MD5: | a5b9a50cf43ac2ccc31f58f2a4d2d546 |
Transpilation MD5: | aa5a5d0ed4b82e95749fd7705be6777b |
Author: | stefan |
Category: | javax / packaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-10-14 13:46:01 |
Source code size: | 1341 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 380 / 481 |
Version history: | 5 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1029946 - resourceLoaderFromDir [untested, but should work] #1031239 - resourceLoaderFromJarOrDir |