LinkFileSystem.java
net.minecraft.server.packs.linkfs.LinkFileSystem
信息
- 全限定名:net.minecraft.server.packs.linkfs.LinkFileSystem
- 类型:public class
- 包:net.minecraft.server.packs.linkfs
- 源码路径:src/main/java/net/minecraft/server/packs/linkfs/LinkFileSystem.java
- 起始行号:L20
- 继承:FileSystem
- 职责:
TODO
字段/常量
-
VIEWS- 类型:
Set<String> - 修饰符:
private static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
PATH_SEPARATOR- 类型:
String - 修饰符:
public static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
PATH_SPLITTER- 类型:
Splitter - 修饰符:
private static final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
store- 类型:
FileStore - 修饰符:
private final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
provider- 类型:
FileSystemProvider - 修饰符:
private final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
root- 类型:
LinkFSPath - 修饰符:
private final - 源码定位:
L26 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.server.packs.linkfs.LinkFileSystem.Builder- 类型:
class - 修饰符:
public static - 源码定位:
L149 - 说明:
TODO
- 类型:
-
net.minecraft.server.packs.linkfs.LinkFileSystem.DirectoryEntry- 类型:
record - 修饰符:
private - 源码定位:
L177 - 说明:
TODO
- 类型:
构造器
private LinkFileSystem(String name, LinkFileSystem.DirectoryEntry rootEntry) @ L28
- 构造器名:LinkFileSystem
- 源码定位:L28
- 修饰符:private
参数:
- name: String
- rootEntry: LinkFileSystem.DirectoryEntry
说明:
TODO
方法
下面的方法块按源码顺序生成。
private static LinkFSPath buildPath(LinkFileSystem.DirectoryEntry entry, LinkFileSystem fileSystem, String selfName, LinkFSPath parent) @ L33
- 方法名:buildPath
- 源码定位:L33
- 返回类型:LinkFSPath
- 修饰符:private static
参数:
- entry: LinkFileSystem.DirectoryEntry
- fileSystem: LinkFileSystem
- selfName: String
- parent: LinkFSPath
说明:
TODO
public FileSystemProvider provider() @ L42
- 方法名:provider
- 源码定位:L42
- 返回类型:FileSystemProvider
- 修饰符:public
参数:
- 无
说明:
TODO
public void close() @ L47
- 方法名:close
- 源码定位:L47
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isOpen() @ L51
- 方法名:isOpen
- 源码定位:L51
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isReadOnly() @ L56
- 方法名:isReadOnly
- 源码定位:L56
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public String getSeparator() @ L61
- 方法名:getSeparator
- 源码定位:L61
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public Iterable<Path> getRootDirectories() @ L66
- 方法名:getRootDirectories
- 源码定位:L66
- 返回类型:Iterable
- 修饰符:public
参数:
- 无
说明:
TODO
public Iterable<FileStore> getFileStores() @ L71
- 方法名:getFileStores
- 源码定位:L71
- 返回类型:Iterable
- 修饰符:public
参数:
- 无
说明:
TODO
public Set<String> supportedFileAttributeViews() @ L76
- 方法名:supportedFileAttributeViews
- 源码定位:L76
- 返回类型:Set
- 修饰符:public
参数:
- 无
说明:
TODO
public Path getPath(String first, String... more) @ L81
- 方法名:getPath
- 源码定位:L81
- 返回类型:Path
- 修饰符:public
参数:
- first: String
- more: String…
说明:
TODO
public PathMatcher getPathMatcher(String syntaxAndPattern) @ L122
- 方法名:getPathMatcher
- 源码定位:L122
- 返回类型:PathMatcher
- 修饰符:public
参数:
- syntaxAndPattern: String
说明:
TODO
public UserPrincipalLookupService getUserPrincipalLookupService() @ L127
- 方法名:getUserPrincipalLookupService
- 源码定位:L127
- 返回类型:UserPrincipalLookupService
- 修饰符:public
参数:
- 无
说明:
TODO
public WatchService newWatchService() @ L132
- 方法名:newWatchService
- 源码定位:L132
- 返回类型:WatchService
- 修饰符:public
参数:
- 无
说明:
TODO
public FileStore store() @ L137
- 方法名:store
- 源码定位:L137
- 返回类型:FileStore
- 修饰符:public
参数:
- 无
说明:
TODO
public LinkFSPath rootPath() @ L141
- 方法名:rootPath
- 源码定位:L141
- 返回类型:LinkFSPath
- 修饰符:public
参数:
- 无
说明:
TODO
public static LinkFileSystem.Builder builder() @ L145
- 方法名:builder
- 源码定位:L145
- 返回类型:LinkFileSystem.Builder
- 修饰符:public static
参数:
- 无
说明:
TODO
代码
public class LinkFileSystem extends FileSystem {
private static final Set<String> VIEWS = Set.of("basic");
public static final String PATH_SEPARATOR = "/";
private static final Splitter PATH_SPLITTER = Splitter.on('/');
private final FileStore store;
private final FileSystemProvider provider = new LinkFSProvider();
private final LinkFSPath root;
private LinkFileSystem(String name, LinkFileSystem.DirectoryEntry rootEntry) {
this.store = new LinkFSFileStore(name);
this.root = buildPath(rootEntry, this, "", null);
}
private static LinkFSPath buildPath(LinkFileSystem.DirectoryEntry entry, LinkFileSystem fileSystem, String selfName, @Nullable LinkFSPath parent) {
Object2ObjectOpenHashMap<String, LinkFSPath> children = new Object2ObjectOpenHashMap<>();
LinkFSPath result = new LinkFSPath(fileSystem, selfName, parent, new PathContents.DirectoryContents(children));
entry.files.forEach((name, linkTarget) -> children.put(name, new LinkFSPath(fileSystem, name, result, new PathContents.FileContents(linkTarget))));
entry.children.forEach((name, childEntry) -> children.put(name, buildPath(childEntry, fileSystem, name, result)));
children.trim();
return result;
}
@Override
public FileSystemProvider provider() {
return this.provider;
}
@Override
public void close() {
}
@Override
public boolean isOpen() {
return true;
}
@Override
public boolean isReadOnly() {
return true;
}
@Override
public String getSeparator() {
return "/";
}
@Override
public Iterable<Path> getRootDirectories() {
return List.of(this.root);
}
@Override
public Iterable<FileStore> getFileStores() {
return List.of(this.store);
}
@Override
public Set<String> supportedFileAttributeViews() {
return VIEWS;
}
@Override
public Path getPath(String first, String... more) {
Stream<String> path = Stream.of(first);
if (more.length > 0) {
path = Stream.concat(path, Stream.of(more));
}
String joinedPath = path.collect(Collectors.joining("/"));
if (joinedPath.equals("/")) {
return this.root;
} else if (joinedPath.startsWith("/")) {
LinkFSPath result = this.root;
for (String segment : PATH_SPLITTER.split(joinedPath.substring(1))) {
if (segment.isEmpty()) {
throw new IllegalArgumentException("Empty paths not allowed");
}
result = result.resolveName(segment);
}
return result;
} else {
LinkFSPath result = null;
for (String segment : PATH_SPLITTER.split(joinedPath)) {
if (segment.isEmpty()) {
throw new IllegalArgumentException("Empty paths not allowed");
}
result = new LinkFSPath(this, segment, result, PathContents.RELATIVE);
}
if (result == null) {
throw new IllegalArgumentException("Empty paths not allowed");
} else {
return result;
}
}
}
@Override
public PathMatcher getPathMatcher(String syntaxAndPattern) {
throw new UnsupportedOperationException();
}
@Override
public UserPrincipalLookupService getUserPrincipalLookupService() {
throw new UnsupportedOperationException();
}
@Override
public WatchService newWatchService() {
throw new UnsupportedOperationException();
}
public FileStore store() {
return this.store;
}
public LinkFSPath rootPath() {
return this.root;
}
public static LinkFileSystem.Builder builder() {
return new LinkFileSystem.Builder();
}
public static class Builder {
private final LinkFileSystem.DirectoryEntry root = new LinkFileSystem.DirectoryEntry();
public LinkFileSystem.Builder put(List<String> path, String name, Path target) {
LinkFileSystem.DirectoryEntry currentEntry = this.root;
for (String segment : path) {
currentEntry = currentEntry.children.computeIfAbsent(segment, n -> new LinkFileSystem.DirectoryEntry());
}
currentEntry.files.put(name, target);
return this;
}
public LinkFileSystem.Builder put(List<String> path, Path target) {
if (path.isEmpty()) {
throw new IllegalArgumentException("Path can't be empty");
} else {
int lastIndex = path.size() - 1;
return this.put(path.subList(0, lastIndex), path.get(lastIndex), target);
}
}
public FileSystem build(String name) {
return new LinkFileSystem(name, this.root);
}
}
private record DirectoryEntry(Map<String, LinkFileSystem.DirectoryEntry> children, Map<String, Path> files) {
public DirectoryEntry() {
this(new HashMap<>(), new HashMap<>());
}
}
}引用的其他类
-
- 引用位置:
构造调用 - 关联成员:
LinkFSFileStore()
- 引用位置:
-
- 引用位置:
参数/字段/构造调用/返回值 - 关联成员:
LinkFSPath()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
LinkFSProvider()
- 引用位置:
-
- 引用位置:
方法调用/构造调用 - 关联成员:
DirectoryContents(), FileContents(), PathContents.DirectoryContents(), PathContents.FileContents()
- 引用位置: