Libraryless. Click here for Pure Java version (4510L/30K).
static IResourceLoader resourceLoaderFromDir(File dir) { ret new IResourceLoader { public S loadSnippet(S snippetID) { ret loadTextFile(newFile(dir, psI(snippetID) + ".text")); } public S getTranspiled(S snippetID) { S src = loadTextFile(newFile(dir, psI(snippetID) + ".transpiled")); if (empty(src)) print("Warning: Transpilation for " + snippetID + " not found"); ret src; } public int getSnippetType(S snippetID) { ret parseInt(loadTextFileTrim(newFile(dir, snippetID + ".type"))); } public S getSnippetTitle(S snippetID) { ret loadTextFileTrim(newFile(dir, snippetID + ".title")); } public File loadLibrary(S snippetID) { long id = psI(snippetID); if (isImageServerSnippet(id)) ret assertIsFile(oneOfTheFilesInDir(dir, id + ".png", id + ".gif")); else ret assertIsFile(newFile(dir, id + ".bin")); } }; }
Began life as a copy of #1022668
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1029946 |
Snippet name: | resourceLoaderFromDir [untested, but should work] |
Eternal ID of this version: | #1029946/5 |
Text MD5: | 4167723a76aac69fcfe2f3586226cb5d |
Transpilation MD5: | 5e06f5703916c17d6083429f397cc654 |
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 14:04:04 |
Source code size: | 979 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 208 / 296 |
Version history: | 4 change(s) |
Referenced in: | [show references] |