static IResourceLoader resourceLoaderFromDirWithInitializing(File dir) { ret new IResourceLoader { public S loadSnippet(S snippetID) ctex { long id = psI(snippetID); File f = newFile(dir, id + ".text"); S text = loadTextFile(f); if (text != null) ret text; saveTextFile(f, text = loadSnippet_noResourceLoader(id, false)); ret text; } public S getTranspiled(S snippetID) { long id = psI(snippetID); File f = newFile(dir, id + ".transpiled"); if (fileExists(f)) ret loadTextFile(f); S src = getServerTranspiled2_noResourceLoader(snippetID); saveTextFile(f, src); ret src; } public int getSnippetType(S snippetID) { long id = psI(snippetID); File f = newFile(dir, id + ".type"); if (fileExists(f)) ret parseInt(loadTextFileTrim(f)); int type = getSnippetType_noResourceLoader(id); saveTextFile(f, str(type)); ret type; } public S getSnippetTitle(S snippetID) { long id = psI(snippetID); File f = newFile(dir, id + ".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(loadBinarySnippet_noResourceLoader(snippetID), f); ret f; } }; }