MCPcopy
hub / github.com/Col-E/Recaf / getFiles

Method getFiles

src/main/java/me/coley/recaf/workspace/JavaResource.java:260–289  ·  view source on GitHub ↗

@return Map of file names to their raw data.

()

Source from the content-addressed store, hash-verified

258 * @return Map of file names to their raw data.
259 */
260 public ListeningMap<String, byte[]> getFiles() {
261 synchronized(cachedFiles) {
262 try {
263 if (!cachedFiles.isBacked()) {
264 cachedFiles.setBacking(copyMap(loadFiles()));
265 // If this resource is not the primary resource, we are done
266 if (!isPrimary())
267 return cachedFiles;
268 // Register listeners
269 cachedFiles.getPutListeners()
270 .add(InternalBiConsumer.internal((name, code) -> dirtyFiles.add(name)));
271 cachedFiles.getRemoveListeners().add(InternalConsumer.internal(dirtyFiles::remove));
272 // Create initial save state
273 for (Map.Entry<String, byte[]> e : cachedFiles.entrySet()) {
274 addFileSave(e.getKey(), e.getValue());
275 }
276 // Add listener to create initial save states for newly made files
277 cachedFiles.getPutListeners().add(InternalBiConsumer.internal((name, code) -> {
278 if (!cachedFiles.containsKey(name)) {
279 addFileSave(name, code);
280 }
281 }));
282 }
283 } catch(IOException ex) {
284 error(ex, "Failed to load files from resource \"{}\"", toString());
285 cachedFiles.setBacking(Collections.emptyMap());
286 }
287 }
288 return cachedFiles;
289 }
290
291 /**
292 * Refresh this resource.

Callers 3

remapManifestTestMethod · 0.95
callMethod · 0.95
callMethod · 0.95

Calls 15

copyMapMethod · 0.95
loadFilesMethod · 0.95
isPrimaryMethod · 0.95
internalMethod · 0.95
internalMethod · 0.95
addFileSaveMethod · 0.95
toStringMethod · 0.95
isBackedMethod · 0.80
getPutListenersMethod · 0.80
getRemoveListenersMethod · 0.80
entrySetMethod · 0.80
getKeyMethod · 0.80

Tested by 1

remapManifestTestMethod · 0.76