Package net.minecraft.util
Class PathUtil
java.lang.Object
net.minecraft.util.PathUtil
A class holding path-related utility methods.
- Mappings:
- Namespace - Name - named - net/minecraft/util/PathUtil- intermediary - net/minecraft/class_4239- official - v
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidcreateDirectories(Path path) A symbolic-link safe version ofFiles.createDirectories(java.nio.file.Path, java.nio.file.attribute.FileAttribute<?>...).static StringgetNextUniqueName(Path path, String name, String extension) Returns a filename, prefixed withname, that does not currently exist insidepath.static PathReturnspathsresolved as a path fromroot.static StringgetPosixFullPath(String path) Returns the full path ofpathwith directory separator normalized to/.static PathgetResourcePath(Path path, String resourceName, String extension) static booleanisAllowedName(Path path) Returns whetherpathdoes not contain reserved Windows file names.static booleanisFileNameValid(String name) Returns whethernameis a valid file name.static booleanReturns whetherpathis already normalized.static StringnormalizeToPosix(String path) Returns the normalized path ofpathwith directory separator normalized to/.static StringreplaceInvalidChars(String fileName) Returnspathsplit by/, or an error result if the path is invalid.static voidvalidatePath(String[] paths) Validates thatpathsis not empty and does not contain invalid segments (such as.,.., or otherwise invalid names).
- 
Field Details- 
FILE_NAME_WITH_COUNT- Mappings:
- Namespace - Name - Mixin selector - named - FILE_NAME_WITH_COUNT- Lnet/minecraft/util/PathUtil;FILE_NAME_WITH_COUNT:Ljava/util/regex/Pattern;- intermediary - field_18956- Lnet/minecraft/class_4239;field_18956:Ljava/util/regex/Pattern;- official - a- Lv;a:Ljava/util/regex/Pattern;
 
- 
MAX_NAME_LENGTHprivate static final int MAX_NAME_LENGTH- See Also:
- Mappings:
- Namespace - Name - Mixin selector - named - MAX_NAME_LENGTH- Lnet/minecraft/util/PathUtil;MAX_NAME_LENGTH:I- intermediary - field_33384- Lnet/minecraft/class_4239;field_33384:I- official - b- Lv;b:I
 
- 
RESERVED_WINDOWS_NAMES- Mappings:
- Namespace - Name - Mixin selector - named - RESERVED_WINDOWS_NAMES- Lnet/minecraft/util/PathUtil;RESERVED_WINDOWS_NAMES:Ljava/util/regex/Pattern;- intermediary - field_18955- Lnet/minecraft/class_4239;field_18955:Ljava/util/regex/Pattern;- official - c- Lv;c:Ljava/util/regex/Pattern;
 
- 
VALID_FILE_NAME- Mappings:
- Namespace - Name - Mixin selector - named - VALID_FILE_NAME- Lnet/minecraft/util/PathUtil;VALID_FILE_NAME:Ljava/util/regex/Pattern;- intermediary - field_40712- Lnet/minecraft/class_4239;field_40712:Ljava/util/regex/Pattern;- official - d- Lv;d:Ljava/util/regex/Pattern;
 
 
- 
- 
Constructor Details- 
PathUtilpublic PathUtil()
 
- 
- 
Method Details- 
replaceInvalidChars- Mappings:
- Namespace - Name - Mixin selector - named - replaceInvalidChars- Lnet/minecraft/util/PathUtil;replaceInvalidChars(Ljava/lang/String;)Ljava/lang/String;- intermediary - method_61105- Lnet/minecraft/class_4239;method_61105(Ljava/lang/String;)Ljava/lang/String;- official - a- Lv;a(Ljava/lang/String;)Ljava/lang/String;
 
- 
getNextUniqueNameReturns a filename, prefixed withname, that does not currently exist insidepath.- Returns:
- a filename, prefixed with name, that does not currently exist insidepath
- Throws:
- IOException- if creating the temporary directory fails, e.g. due to- pathnot being a directory
- Implementation Note:
- This strips any illegal characters from name, then attempts to make a directory with the name and the extension. If this succeeds, the directory is deleted and the name with the extension is returned. If not, it appends(1)to the name and tries again until it succeeds.
- Mappings:
- Namespace - Name - Mixin selector - named - getNextUniqueName- Lnet/minecraft/util/PathUtil;getNextUniqueName(Ljava/nio/file/Path;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;- intermediary - method_19773- Lnet/minecraft/class_4239;method_19773(Ljava/nio/file/Path;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;- official - a- Lv;a(Ljava/nio/file/Path;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
 
- 
isNormalReturns whetherpathis already normalized.- Returns:
- whether pathis already normalized
- Mappings:
- Namespace - Name - Mixin selector - named - isNormal- Lnet/minecraft/util/PathUtil;isNormal(Ljava/nio/file/Path;)Z- intermediary - method_20200- Lnet/minecraft/class_4239;method_20200(Ljava/nio/file/Path;)Z- official - a- Lv;a(Ljava/nio/file/Path;)Z
 
- 
isAllowedNameReturns whetherpathdoes not contain reserved Windows file names.- Returns:
- whether pathdoes not contain reserved Windows file names
- API Note:
- This returns falsefor reserved names regardless of whether the platform the game is running is actually Windows. Note that this does not check for illegal characters or file permissions.
- Mappings:
- Namespace - Name - Mixin selector - named - isAllowedName- Lnet/minecraft/util/PathUtil;isAllowedName(Ljava/nio/file/Path;)Z- intermediary - method_20201- Lnet/minecraft/class_4239;method_20201(Ljava/nio/file/Path;)Z- official - b- Lv;b(Ljava/nio/file/Path;)Z
 
- 
getResourcePath- Mappings:
- Namespace - Name - Mixin selector - named - getResourcePath- Lnet/minecraft/util/PathUtil;getResourcePath(Ljava/nio/file/Path;Ljava/lang/String;Ljava/lang/String;)Ljava/nio/file/Path;- intermediary - method_20202- Lnet/minecraft/class_4239;method_20202(Ljava/nio/file/Path;Ljava/lang/String;Ljava/lang/String;)Ljava/nio/file/Path;- official - b- Lv;b(Ljava/nio/file/Path;Ljava/lang/String;Ljava/lang/String;)Ljava/nio/file/Path;
 
- 
getPosixFullPathReturns the full path ofpathwith directory separator normalized to/.- Returns:
- the full path of pathwith directory separator normalized to/
- Mappings:
- Namespace - Name - Mixin selector - named - getPosixFullPath- Lnet/minecraft/util/PathUtil;getPosixFullPath(Ljava/lang/String;)Ljava/lang/String;- intermediary - method_34675- Lnet/minecraft/class_4239;method_34675(Ljava/lang/String;)Ljava/lang/String;- official - b- Lv;b(Ljava/lang/String;)Ljava/lang/String;
 
- 
normalizeToPosixReturns the normalized path ofpathwith directory separator normalized to/.- Returns:
- the normalized path of pathwith directory separator normalized to/
- Mappings:
- Namespace - Name - Mixin selector - named - normalizeToPosix- Lnet/minecraft/util/PathUtil;normalizeToPosix(Ljava/lang/String;)Ljava/lang/String;- intermediary - method_34676- Lnet/minecraft/class_4239;method_34676(Ljava/lang/String;)Ljava/lang/String;- official - c- Lv;c(Ljava/lang/String;)Ljava/lang/String;
 
- 
splitReturnspathsplit by/, or an error result if the path is invalid.All path segments must be a valid file name. Additionally, .and..are forbidden.- Returns:
- pathsplit by- /, or an error result if the path is invalid
- Mappings:
- Namespace - Name - Mixin selector - named - split- Lnet/minecraft/util/PathUtil;split(Ljava/lang/String;)Lcom/mojang/serialization/DataResult;- intermediary - method_46346- Lnet/minecraft/class_4239;method_46346(Ljava/lang/String;)Lcom/mojang/serialization/DataResult;- official - d- Lv;d(Ljava/lang/String;)Lcom/mojang/serialization/DataResult;
 
- 
getPathReturnspathsresolved as a path fromroot.If pathsis empty, this returnsroot.- Returns:
- pathsresolved as a path from- root
- Mappings:
- Namespace - Name - Mixin selector - named - getPath- Lnet/minecraft/util/PathUtil;getPath(Ljava/nio/file/Path;Ljava/util/List;)Ljava/nio/file/Path;- intermediary - method_46344- Lnet/minecraft/class_4239;method_46344(Ljava/nio/file/Path;Ljava/util/List;)Ljava/nio/file/Path;- official - a- Lv;a(Ljava/nio/file/Path;Ljava/util/List;)Ljava/nio/file/Path;
 
- 
isFileNameValidReturns whethernameis a valid file name.- Returns:
- whether nameis a valid file name
- API Note:
- A valid file name contains only ASCII lowercase alphabets, ASCII digits,
 a dot, or an underscore. Unlike Identifierpaths, hyphens are not allowed.
- Mappings:
- Namespace - Name - Mixin selector - named - isFileNameValid- Lnet/minecraft/util/PathUtil;isFileNameValid(Ljava/lang/String;)Z- intermediary - method_46347- Lnet/minecraft/class_4239;method_46347(Ljava/lang/String;)Z- official - e- Lv;e(Ljava/lang/String;)Z
 
- 
validatePathValidates thatpathsis not empty and does not contain invalid segments (such as.,.., or otherwise invalid names).- Throws:
- IllegalArgumentException- when the- pathsare invalid
- Mappings:
- Namespace - Name - Mixin selector - named - validatePath- Lnet/minecraft/util/PathUtil;validatePath([Ljava/lang/String;)V- intermediary - method_46345- Lnet/minecraft/class_4239;method_46345([Ljava/lang/String;)V- official - a- Lv;a([Ljava/lang/String;)V
 
- 
createDirectoriesA symbolic-link safe version ofFiles.createDirectories(java.nio.file.Path, java.nio.file.attribute.FileAttribute<?>...).- Throws:
- IOException
- Mappings:
- Namespace - Name - Mixin selector - named - createDirectories- Lnet/minecraft/util/PathUtil;createDirectories(Ljava/nio/file/Path;)V- intermediary - method_47525- Lnet/minecraft/class_4239;method_47525(Ljava/nio/file/Path;)V- official - c- Lv;c(Ljava/nio/file/Path;)V
 
 
-