@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 |
|---|---|
FileUtilities.FileType |
checkFileType(java.io.File file)
Check the given file for its type, whether it is a regular file, a Windows link or a UNIX
symlink.
|
FileUtilities.FileType |
checkFileType(java.lang.String file)
Check the given file for its type, whether it is a regular file, a Windows link or a UNIX
symlink.
|
boolean |
checkPermissions(java.io.File fileOrDirectory)
Check the given file or directory for read- and write-permission.
|
boolean |
checkPermissions(java.nio.file.Path fileOrDirectory)
Check the given file or directory for read- and write-permission.
|
boolean |
checkPermissions(java.lang.String fileOrDirectory)
Check the given file or directory for read- and write-permission.
|
boolean |
checkReadPermission(java.io.File fileOrDirectory)
Check the given file or directory for read-permission.
|
boolean |
checkReadPermission(java.nio.file.Path fileOrDirectory)
Check the given file or directory for read-permission.
|
boolean |
checkReadPermission(java.lang.String fileOrDirectory)
Check the given file or directory for read-permission.
|
boolean |
checkWritePermission(java.io.File fileOrDirectory)
Check the given file or directory for write-permission.
|
boolean |
checkWritePermission(java.nio.file.Path fileOrDirectory)
Check the given file or directory for write-permission.
|
boolean |
checkWritePermission(java.lang.String fileOrDirectory)
Check the given file or directory for write-permission.
|
void |
createDirectories(java.nio.file.Path directory)
Create a directory, including any necessary parent directories.
|
boolean |
isLink(java.io.File file)
Check if the given file is a UNIX symlink or Windows lnk.
|
boolean |
isLink(java.lang.String file)
Check if the given file is a UNIX symlink or Windows lnk.
|
void |
openFile(java.lang.String fileToOpen)
Open the specified file in an editor.
|
void |
openFolder(java.lang.String folder)
Open the specified folder in the file explorer.
|
boolean |
replaceFile(java.io.File sourceFile,
java.io.File destinationFile)
Move a file from source to destination, and replace the destination file if it exists.
|
java.lang.String |
resolveLink(java.io.File link)
Resolve a given link/symlink to its source.
|
java.lang.String |
resolveLink(java.lang.String link)
Resolve a given link/symlink to its source.
|
void |
unzipArchive(java.lang.String zipFile,
java.lang.String destinationDirectory)
Unzips the downloaded modpack ZIP-archive to the specified directory.
|
public boolean replaceFile(java.io.File sourceFile,
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(java.nio.file.Path directory)
directory - The directory to create.public void unzipArchive(java.lang.String zipFile,
java.lang.String destinationDirectory)
zipFile - String. The path to the ZIP-archive which we want to unzip.destinationDirectory - The directory into which the ZIP-archive will be unzipped into.public FileUtilities.FileType checkFileType(java.lang.String file)
file - The file to checkFileUtilities.FileType.FILE, FileUtilities.FileType.LINK or
FileUtilities.FileType.SYMLINKpublic FileUtilities.FileType checkFileType(java.io.File file)
file - The file to checkFileUtilities.FileType.FILE, FileUtilities.FileType.LINK or
FileUtilities.FileType.SYMLINKpublic boolean isLink(java.lang.String file)
file - The file to check.true if the given file is a UNIX symlink or Windows lnk.public boolean isLink(java.io.File file)
file - The file to check.true if the given file is a UNIX symlink or Windows lnk.public java.lang.String resolveLink(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.public java.lang.String resolveLink(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 checkPermissions(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 checkPermissions(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 checkPermissions(java.nio.file.Path fileOrDirectory)
fileOrDirectory - File or directory.true if both read- and write-permissions are set.public boolean checkReadPermission(java.lang.String fileOrDirectory)
fileOrDirectory - File or directory.true if read-permissions are set.public boolean checkReadPermission(java.io.File fileOrDirectory)
fileOrDirectory - File or directory.true if read-permissions are set.public boolean checkReadPermission(java.nio.file.Path fileOrDirectory)
fileOrDirectory - File or directory.true if read-permissions are set.public boolean checkWritePermission(java.lang.String fileOrDirectory)
fileOrDirectory - File or directory.true if write-permissions are set.public boolean checkWritePermission(java.io.File fileOrDirectory)
fileOrDirectory - File or directory.true if write-permissions are set.public boolean checkWritePermission(java.nio.file.Path fileOrDirectory)
fileOrDirectory - File or directory.true if write-permissions are set.public void openFolder(java.lang.String folder)
folder - The folder to open.public void openFile(java.lang.String fileToOpen)
fileToOpen - The file to open.