public class PathUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Path |
absoluteToJIPipeUserDirRelative(Path path) |
static String |
computeFileSHA1(File file)
Computes the SHA1 of a file
|
static void |
copyDirectory(Path sourcePath,
Path targetPath,
JIPipeProgressInfo progressInfo) |
static void |
copyDirectory(Path sourcePath,
Path targetPath,
Predicate<Path> directoryFilter,
JIPipeProgressInfo progressInfo) |
static void |
copyOrLink(Path source,
Path target,
JIPipeProgressInfo progressInfo) |
static void |
createDirectories(Path path) |
static Path |
createTempDirectory(Path root,
String prefix) |
static void |
deleteDirectoryRecursively(Path path,
JIPipeProgressInfo progressInfo) |
static boolean |
ensureEmptyFolder(Component parent,
Path path)
Ensures that the path exists and is empty
|
static Path |
ensureExtension(Path path,
String extension,
String... alternativeExtensions)
Ensures that the file name of the path has one of the provided extensions
|
static void |
ensureParentDirectoriesExist(Path path)
Ensures that the parent directories of the path exist.
|
static Path |
findAnyOf(Path... paths)
Returns the first path that exists
|
static Path |
findFileByExtensionIn(Path folder,
String... extensions)
Finds a file in the specified folder with given extension
|
static Path |
findFileByExtensionRecursivelyIn(Path folder,
String... extensions)
Finds a file in the specified folder with given extension
|
static List<Path> |
findFilesByExtensionIn(Path folder,
String... extensions)
Finds a file in the specified folder with given extension
|
static Path |
getImageJDir()
Gets the ImageJ directory
|
static Path |
getJIPipeUserDir()
Returns the JIPipe user directory
|
static Path |
getJIPipeUserDirBase()
Returns the base directory that contains all profiles
|
static Path |
getLegacyJIPipeUserDir()
Gets the legacy user directory.
|
static List<Path> |
listSubDirectories(Path folder)
Finds a file in the specified folder with given extension
|
static void |
makeAllUnixExecutable(Path dir,
JIPipeProgressInfo progressInfo)
Marks all files in that directory as Unix executable
|
static void |
makeUnixExecutable(Path path)
Makes a file/directory executable
Does nothing if the OS is Windows
|
static Path |
normalize(Path path) |
static void |
normalizeList(List<Path> paths)
Converts UNIX paths to Windows and Windows paths to UNIX
|
static Path |
orElse(Path firstChoice,
Path alternative)
Returns the first path if it exists or the alternative path if it doesn't
|
static Path |
relativeJIPipeUserDirToAbsolute(Path path)
Converts relative paths to absolute paths, relative to the ImageJ directory
Absolute paths are left unchanged
|
static Path |
resolveAndMakeSubDirectory(Path directory,
Path name) |
static Path |
resolveAndMakeSubDirectory(Path directory,
String name) |
public static void makeUnixExecutable(Path path)
path
- the pathpublic static Path resolveAndMakeSubDirectory(Path directory, String name)
public static void copyDirectory(Path sourcePath, Path targetPath, JIPipeProgressInfo progressInfo)
public static void copyDirectory(Path sourcePath, Path targetPath, Predicate<Path> directoryFilter, JIPipeProgressInfo progressInfo)
public static void deleteDirectoryRecursively(Path path, JIPipeProgressInfo progressInfo)
public static String computeFileSHA1(File file) throws IOException
file
- the fileIOException
- exceptionpublic static void copyOrLink(Path source, Path target, JIPipeProgressInfo progressInfo)
public static Path findFileByExtensionIn(Path folder, String... extensions)
folder
- the pathextensions
- Should contain the dotpublic static Path findFileByExtensionRecursivelyIn(Path folder, String... extensions)
folder
- the pathextensions
- Should contain the dotpublic static List<Path> findFilesByExtensionIn(Path folder, String... extensions)
folder
- the pathextensions
- Should contain the dotpublic static List<Path> listSubDirectories(Path folder)
folder
- the pathpublic static void normalizeList(List<Path> paths)
paths
- the paths. This list must be modifiablepublic static Path findAnyOf(Path... paths)
paths
- pathspublic static Path getLegacyJIPipeUserDir()
public static Path getJIPipeUserDirBase()
public static Path getJIPipeUserDir()
public static Path getImageJDir()
public static Path relativeJIPipeUserDirToAbsolute(Path path)
path
- the pathpublic static boolean ensureEmptyFolder(Component parent, Path path)
parent
- the parent component for the dialog boxpath
- the pathpublic static Path ensureExtension(Path path, String extension, String... alternativeExtensions)
path
- the pathextension
- the extension (should include the dot)alternativeExtensions
- alternative extensions that are also valid (should include the dot)public static void ensureParentDirectoriesExist(Path path)
path
- the pathpublic static Path orElse(Path firstChoice, Path alternative)
firstChoice
- the first choice. can be null.alternative
- the alternativepublic static void makeAllUnixExecutable(Path dir, JIPipeProgressInfo progressInfo)
dir
- the directoryprogressInfo
- the progresspublic static void createDirectories(Path path)
Copyright © 2020–2024 Leibniz Institute for Natural Product Research and Infection Biology - Hans Knöll Institute (HKI). All rights reserved.