@Component
public final class FileUtilities
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
FileUtilities.FileType |
| Constructor and Description |
|---|
FileUtilities() |
| Modifier and Type | Method and Description |
|---|---|
@NotNull FileUtilities.FileType |
checkFileType(@NotNull java.io.File file)
Check the given file for its type, whether it is a regular file, a Windows link or a UNIX
symlink.
|
@NotNull FileUtilities.FileType |
checkFileType(@NotNull java.lang.String file)
Check the given file for its type, whether it is a regular file, a Windows link or a UNIX
symlink.
|
void |
createDirectories(@NotNull java.nio.file.Path directory)
Create a directory, including any necessary parent directories.
|
boolean |
isLink(@NotNull java.io.File file)
Check if the given file is a UNIX symlink or Windows lnk.
|
boolean |
isLink(@NotNull java.lang.String file)
Check if the given file is a UNIX symlink or Windows lnk.
|
boolean |
isReadPermissionSet(@NotNull java.io.File fileOrDirectory)
Check the given file or directory for read-permission.
|
boolean |
isReadPermissionSet(@NotNull java.nio.file.Path fileOrDirectory)
Check the given file or directory for read-permission.
|
boolean |
isReadPermissionSet(@NotNull java.lang.String fileOrDirectory)
Check the given file or directory for read-permission.
|
boolean |
isReadWritePermissionSet(@NotNull java.io.File fileOrDirectory)
Check the given file or directory for read- and write-permission.
|
boolean |
isReadWritePermissionSet(@NotNull java.nio.file.Path fileOrDirectory)
Check the given file or directory for read- and write-permission.
|
boolean |
isReadWritePermissionSet(@NotNull java.lang.String fileOrDirectory)
Check the given file or directory for read- and write-permission.
|
boolean |
isWritePermissionSet(@NotNull java.io.File fileOrDirectory)
Check the given file or directory for write-permission.
|
boolean |
isWritePermissionSet(@NotNull java.nio.file.Path fileOrDirectory)
Check the given file or directory for write-permission.
|
boolean |
isWritePermissionSet(@NotNull java.lang.String fileOrDirectory)
Check the given file or directory for write-permission.
|
void |
openFile(@NotNull java.io.File fileToOpen)
Open the specified file in an editor.
|
void |
openFile(@NotNull java.lang.String fileToOpen)
Open the specified file in an editor.
|
void |
openFolder(@NotNull java.io.File folder)
Open the specified folder in the file explorer.
|
void |
openFolder(@NotNull java.lang.String folder)
Open the specified folder in the file explorer.
|
boolean |
replaceFile(@NotNull java.io.File sourceFile,
@NotNull java.io.File destinationFile)
Move a file from source to destination, and replace the destination file if it exists.
|
@NotNull java.lang.String |
resolveLink(@NotNull java.io.File link)
Resolve a given link/symlink to its source.
|
@NotNull java.lang.String |
resolveLink(@NotNull java.lang.String link)
Resolve a given link/symlink to its source.
|
void |
unzipArchive(@NotNull java.lang.String zipFile,
@NotNull java.lang.String destinationDirectory)
Unzips the downloaded modpack ZIP-archive to the specified directory.
|
public boolean replaceFile(@NotNull
@NotNull java.io.File sourceFile,
@NotNull
@NotNull java.io.File destinationFile)
throws java.io.IOException
sourceFile - The source file.destinationFile - The destination file to be replaced by the source file.java.io.IOException - Thrown if an error occurs when the file is moved.public void createDirectories(@NotNull
@NotNull java.nio.file.Path directory)
directory - The directory to create.public void unzipArchive(@NotNull
@NotNull java.lang.String zipFile,
@NotNull
@NotNull java.lang.String destinationDirectory)
zipFile - The path to the ZIP-archive which we want to unzip.destinationDirectory - The directory into which the ZIP-archive will be unzipped into.@NotNull public @NotNull FileUtilities.FileType checkFileType(@NotNull @NotNull java.lang.String file)
file - The file to checkFileUtilities.FileType.FILE, FileUtilities.FileType.LINK or
FileUtilities.FileType.SYMLINK@NotNull public @NotNull FileUtilities.FileType checkFileType(@NotNull @NotNull java.io.File file)
file - The file to checkFileUtilities.FileType.FILE, FileUtilities.FileType.LINK or
FileUtilities.FileType.SYMLINKpublic boolean isLink(@NotNull
@NotNull java.lang.String file)
file - The file to check.true if the given file is a UNIX symlink or Windows lnk.public boolean isLink(@NotNull
@NotNull java.io.File file)
file - The file to check.true if the given file is a UNIX symlink or Windows lnk.@NotNull
public @NotNull java.lang.String resolveLink(@NotNull
@NotNull java.lang.String link)
throws InvalidFileTypeException,
java.io.IOException
link - The link you want to resolve.java.io.IOException - if the link could not be parsed.InvalidFileTypeException - if the specified file is neither a file, lnk nor symlink.@NotNull
public @NotNull java.lang.String resolveLink(@NotNull
@NotNull java.io.File link)
throws java.io.IOException,
InvalidFileTypeException
link - The link you want to resolve.java.io.IOException - if the link could not be parsed.InvalidFileTypeException - if the specified file is neither a file, lnk nor symlink.public boolean isReadWritePermissionSet(@NotNull
@NotNull java.lang.String fileOrDirectory)
throws java.nio.file.InvalidPathException
fileOrDirectory - File or directory.true if both read- and write-permissions are set.java.nio.file.InvalidPathException - if the path string cannot be converted to a Path.public boolean isReadWritePermissionSet(@NotNull
@NotNull java.nio.file.Path fileOrDirectory)
fileOrDirectory - File or directory.true if both read- and write-permissions are set.public boolean isReadPermissionSet(@NotNull
@NotNull java.nio.file.Path fileOrDirectory)
fileOrDirectory - File or directory.true if read-permissions are set.public boolean isWritePermissionSet(@NotNull
@NotNull java.nio.file.Path fileOrDirectory)
fileOrDirectory - File or directory.true if write-permissions are set.public boolean isReadWritePermissionSet(@NotNull
@NotNull java.io.File fileOrDirectory)
throws java.nio.file.InvalidPathException
fileOrDirectory - File or directory.true if both read- and write-permissions are set.java.nio.file.InvalidPathException - if a Path object cannot be constructed from the abstract
path (see
FileSystem.getPath)public boolean isReadPermissionSet(@NotNull
@NotNull java.lang.String fileOrDirectory)
fileOrDirectory - File or directory.true if read-permissions are set.public boolean isReadPermissionSet(@NotNull
@NotNull java.io.File fileOrDirectory)
fileOrDirectory - File or directory.true if read-permissions are set.public boolean isWritePermissionSet(@NotNull
@NotNull java.lang.String fileOrDirectory)
fileOrDirectory - File or directory.true if write-permissions are set.public boolean isWritePermissionSet(@NotNull
@NotNull java.io.File fileOrDirectory)
fileOrDirectory - File or directory.true if write-permissions are set.public void openFolder(@NotNull
@NotNull java.lang.String folder)
folder - The folder to open.public void openFolder(@NotNull
@NotNull java.io.File folder)
folder - The folder to open.public void openFile(@NotNull
@NotNull java.lang.String fileToOpen)
fileToOpen - The file to open.public void openFile(@NotNull
@NotNull java.io.File fileToOpen)
fileToOpen - The file to open.