Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

51
LINES

< > BotCompany Repo | #1029949 // resourceLoaderFromDirWithInitializing [loads missing code from code.botcompany.de]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5478L/37K).

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;
    }
  };
}

Author comment

Began life as a copy of #1029946

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1029949
Snippet name: resourceLoaderFromDirWithInitializing [loads missing code from code.botcompany.de]
Eternal ID of this version: #1029949/11
Text MD5: 0bb125c28582d9323fe49b603a8deded
Transpilation MD5: 68003a74b6fbc1cab3aa118ce3e15c2f
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:41:55
Source code size: 1619 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 221 / 326
Version history: 10 change(s)
Referenced in: [show references]