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).

1  
static IResourceLoader resourceLoaderFromDirWithInitializing(File dir) {
2  
  ret new IResourceLoader {
3  
    public S loadSnippet(S snippetID) ctex {
4  
      long id = psI(snippetID);
5  
      File f = newFile(dir, id + ".text");
6  
      S text = loadTextFile(f);
7  
      if (text != null) ret text;
8  
      saveTextFile(f, text = loadSnippet_noResourceLoader(id, false));
9  
      ret text;
10  
    }
11  
    
12  
    public S getTranspiled(S snippetID) {
13  
      long id = psI(snippetID);
14  
      File f = newFile(dir, id + ".transpiled");
15  
      if (fileExists(f))
16  
        ret loadTextFile(f);
17  
      S src = getServerTranspiled2_noResourceLoader(snippetID);
18  
      saveTextFile(f, src);
19  
      ret src;
20  
    }
21  
    
22  
    public int getSnippetType(S snippetID) {
23  
      long id = psI(snippetID);
24  
      File f = newFile(dir, id + ".type");
25  
      if (fileExists(f))
26  
        ret parseInt(loadTextFileTrim(f));
27  
      int type = getSnippetType_noResourceLoader(id);
28  
      saveTextFile(f, str(type));
29  
      ret type;
30  
    }
31  
    
32  
    public S getSnippetTitle(S snippetID) {
33  
      long id = psI(snippetID);
34  
      File f = newFile(dir, id + ".title");
35  
      if (fileExists(f))
36  
        ret loadTextFileTrim(f);
37  
      S title = getSnippetTitle_noResourceLoader(snippetID);
38  
      saveTextFile(f, title);
39  
      ret title;
40  
    }
41  
    
42  
    public File loadLibrary(S snippetID) {
43  
      long id = psI(snippetID);
44  
      File f = newFile(dir, isImageServerSnippet(id) ? id + ".png" : id + ".bin");
45  
      if (fileExists(f))
46  
        ret f;
47  
      copyFile(loadBinarySnippet_noResourceLoader(snippetID), f);
48  
      ret f;
49  
    }
50  
  };
51  
}

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: 222 / 328
Version history: 10 change(s)
Referenced in: [show references]