Class FolderJarContents
- All Implemented Interfaces:
Closeable,AutoCloseable,JarContents
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface net.neoforged.fml.jarcontents.JarContents
JarContents.FilteredPath, JarContents.PathFilter -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleancontainsFile(String relativePath) Checks, if a given file exists in this jar.Looks for a file in the jar.private PathfromRelativePath(String relativePath) @Nullable JarResourceTries to find a resource with the given path in this jar content.Returns SHA-256 hash of the contents, if available.Returns the locations that this Jar content was opened from.Returns the manifest of the jar.private PathgetVisitStartingPoint(String startingFolder) Tries to open a file inside the jar content using a path relative to the root.byte[]A convenience method that opens a file and if the file was found, returns its content.toString()voidvisitContent(String startingFolder, JarResourceVisitor visitor) Visits all content found in this jar, starting in the given folder.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.neoforged.fml.jarcontents.JarContents
visitContent
-
Field Details
-
path
-
manifestLock
-
cachedManifest
-
-
Constructor Details
-
FolderJarContents
-
-
Method Details
-
getPrimaryPath
- Specified by:
getPrimaryPathin interfaceJarContents
-
getChecksum
Description copied from interface:JarContentsReturns SHA-256 hash of the contents, if available.This value is intended to be used as a cache-key, and will be empty if the jar contents are not stable enough to be cached (i.e. they're sourced from memory or a folder).
- Specified by:
getChecksumin interfaceJarContents- Returns:
- SHA-256 hash of the contents, if available
-
get
Description copied from interface:JarContentsTries to find a resource with the given path in this jar content.- Specified by:
getin interfaceJarContents- Parameters:
relativePath- SeeJarContentsfor a definition of relative paths.- Returns:
- Null if the resource could not be found within the jar, or if
relativePathrefers to a directory.
-
containsFile
Description copied from interface:JarContentsChecks, if a given file exists in this jar.- Specified by:
containsFilein interfaceJarContents- Parameters:
relativePath- The path to the file, relative to the root of this Jar file.- Returns:
- True if the file exists, false if it doesn't or
relativePathrefers to a directory.
-
openFile
Description copied from interface:JarContentsTries to open a file inside the jar content using a path relative to the root.The stream will not be buffered.
The behavior when
relativePathrefers to a directory rather than a file is unspecified. The method may throw aIOExceptionimmediately, but may also defer this until the first byte is read from the stream. This behavior is filesystem provider specific.- Specified by:
openFilein interfaceJarContents- Returns:
- null if the file cannot be found
- Throws:
IOException
-
readFile
Description copied from interface:JarContentsA convenience method that opens a file and if the file was found, returns its content.Trying to read the contents of a directory using this method will throw an
IOException.- Specified by:
readFilein interfaceJarContents- Returns:
- Null if the file does not exist.
- Throws:
IOException
-
getContentRoots
Description copied from interface:JarContentsReturns the locations that this Jar content was opened from.Usually this will only contain a single path, for example to the Jar file that was opened, but especially during development, it can contain multiple build output folders that were joined into a single virtual Jar file.
The resulting paths do not need to be on the local file-system, they can be from custom NIO filesystem implementations.
The returned list may also not contain all content roots if the underlying jar content is held in-memory.
- Specified by:
getContentRootsin interfaceJarContents
-
visitContent
Description copied from interface:JarContentsVisits all content found in this jar, starting in the given folder.If the folder does not exist, the visitor is not invoked and no error is raised.
- Specified by:
visitContentin interfaceJarContents
-
getVisitStartingPoint
-
findFile
Description copied from interface:JarContentsLooks for a file in the jar.- Specified by:
findFilein interfaceJarContents- Returns:
- A URI for the file, or empty if the file cannot be found or if
relativePathrefers to a directory.
-
getManifest
Description copied from interface:JarContentsReturns the manifest of the jar. Empty if no manifest is present in the jar.NOTE: Do not modify the returned manifest.
- Specified by:
getManifestin interfaceJarContents- Returns:
- the manifest of the jar
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
toString
-
fromRelativePath
-