FileNode .java

net.minecraft.util.filefix.virtualfilesystem.FileNode (class, 37 lines): extends Node. members: storagePath, deleteCopy, ensureCopy, isCopy.

net.minecraft.util.filefix.virtualfilesystemclass37 linescommonextends Node889 B

API Surface (3)

void ensureCopy()
void deleteCopy()
Path storagePath()

Fields & Constants (2)

storagePath
isCopy

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

FileNode.java37 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.filefix.virtualfilesystem;
2
3
import java.io.IOException;
4
import java.nio.file.Files;
5
import java.nio.file.Path;
6
import java.nio.file.StandardCopyOption;
7
8
final class FileNode extends Node {
9
	private Path storagePath;
10
	boolean isCopy;
11
12
	FileNode(final CopyOnWriteFSPath path, final Path storagePath, final boolean isCopy) {
13
		super(path);
14
		this.storagePath = storagePath;
15
		this.isCopy = isCopy;
16
	}
17
18
	public void ensureCopy() throws IOException {
19
		if (!this.isCopy) {
20
			Path tempFile = this.path.getFileSystem().createTemporaryFilePath();
21
			Files.copy(this.storagePath, tempFile, StandardCopyOption.COPY_ATTRIBUTES);
22
			this.storagePath = tempFile;
23
			this.isCopy = true;
24
		}
25
	}
26
27
	public void deleteCopy() throws IOException {
28
		if (this.isCopy) {
29
			Files.deleteIfExists(this.storagePath);
30
		}
31
	}
32
33
	public Path storagePath() {
34
		return this.storagePath;
35
	}
36
}
37

Decompiled Minecraft 26.3 source of FileNode (net/minecraft/util/filefix/virtualfilesystem/FileNode.java) with Mojang official mappings, stored verbatim on the site.