static IResourceLoader resourceLoaderFromDirWithInitializing(File dir) { ret new IResourceLoader { public S loadSnippet(S snippetID) { File f = newFile(dir, psI(snippetID) + ".text"); S text = loadTextFile(f); if (text != null) ret text; saveTextFile(f, text = loadSnippet_noResourceLoader(snippetID)); ret 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) { File f = newFile(dir, snippetID + ".type"); if (fileExists(f)) ret parseInt(loadTextFileTrim(f)); int type = getSnippetType_noResourceLoader(snippetID); saveTextFile(f, str(type)); ret type; } public S getSnippetTitle(S snippetID) { File f = newFile(dir, snippetID + ".title"); if (fileExists(f)) ret loadTextFileTrim(f); S title = getSnippetTitle_noResourceLoader(snippetID); saveTextFile(f, title); ret title; } public File loadLibrary(S snippetID) { long id = psI(snippetID); File f = newFile(dir, isImageServerSnippet(id) ? id + ".png" : id + ".bin"); if (fileExists(f)) ret f; copyFile(loadLibrary_noResourceLoader(snippetID), f); ret f; } }; }