MCPcopy Create free account
hub / github.com/Card-Forge/forge / getFile

Method getFile

forge-gui-mobile/src/forge/adventure/util/Config.java:205–234  ·  view source on GitHub ↗
(String path)

Source from the content-addressed store, hash-verified

203 }
204
205 public FileHandle getFile(String path) {
206 if (Cache.containsKey(path)) return Cache.get(path);
207
208 //if (Cache.containsKey(commonPath)) return Cache.get(commonPath);
209
210 //not cached, look for resource
211 System.out.print("Looking for resource " + path + "... ");
212 String fullPath = (prefix + path).replace("//", "/");
213 String fileName = fullPath.replaceFirst("[.][^.]+$", "");
214 String ext = fullPath.substring(fullPath.lastIndexOf('.'));
215 String langFile = fileName + "-" + Lang + ext;
216
217 for (int iter = 1; iter <= 2; iter++) {
218
219 if (Files.exists(Paths.get(langFile))) {
220 System.out.println("Found!");
221 Cache.put(path, new FileHandle(langFile));
222 break;
223 } else if (Files.exists(Paths.get(fullPath))) {
224 System.out.println("Found!");
225 Cache.put(path, new FileHandle(fullPath));
226 break;
227 }
228 //no local resource, check common resources
229 fullPath = (commonPrefix + path).replace("//", "/");
230 fileName = fullPath.replaceFirst("[.][^.]+$", "");
231 langFile = fileName + "-" + Lang + ext;
232 }
233 return Cache.get(path);
234 }
235
236 public String getPlane() {
237 return plane.replace("<user>", "user_");

Callers 15

getAtlasMethod · 0.95
saveMethod · 0.45
loadMethod · 0.45
saveMethod · 0.45
saveBiomeMethod · 0.45
saveMethod · 0.45
loadMethod · 0.45
updateMethod · 0.45

Calls 6

containsKeyMethod · 0.80
printMethod · 0.80
getMethod · 0.65
lastIndexOfMethod · 0.65
replaceMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected