Modifier and Type | Class and Description |
---|---|
static interface |
BambooFiles.AutoRemoved |
static interface |
BambooFiles.QuietlyRemoved |
Constructor and Description |
---|
BambooFiles() |
Modifier and Type | Method and Description |
---|---|
static BambooFiles.AutoRemoved |
autoRemoved(Path path)
Wraps the supplied
Path with AutoCloseable . |
static Path |
createTempDirectory(Path dir,
String prefix,
FileAttribute<?>... attrs)
|
static void |
delete(Path path)
Deletes files, including readonly files on Windows.
|
static void |
deleteLogIfError(Path path,
org.apache.log4j.Logger logger)
Call
delete(Path) and logs exception if happens. |
static boolean |
deleteQuietly(Path path)
Deletes a path quietly, returns true on success.
|
static boolean |
isExecutable(Path path) |
static BambooFiles.QuietlyRemoved |
quietlyRemoved(Path path)
Wraps the supplied
Path with AutoCloseable . |
static Path |
resolvePathUnderParent(Path parent,
String child)
Fulfills the general contract of
Path.resolve(String) . |
static void |
setAccessibleOnlyByOwner(Path path)
Removes access to
Path from non-owners. |
static void |
setExecutable(Path path,
boolean isExecutable)
Sets executable bit on
Path |
static void |
setReadOnly(Path path,
boolean isReadOnly)
Sets readonly bit on
Path |
public static boolean deleteQuietly(Path path)
public static void delete(Path path) throws IOException
IOException
public static void deleteLogIfError(Path path, org.apache.log4j.Logger logger)
delete(Path)
and logs exception if happens.public static boolean isExecutable(Path path) throws IOException
IOException
public static BambooFiles.AutoRemoved autoRemoved(Path path)
public static BambooFiles.QuietlyRemoved quietlyRemoved(Path path)
Path
with AutoCloseable
. The directory will be quietly deleted on AutoCloseable.close()
public static Path createTempDirectory(Path dir, String prefix, FileAttribute<?>... attrs) throws IOException
Files.createTempDirectory(Path, String, FileAttribute[])
. This function will create the parent directories if they do not exist.IOException
public static void setReadOnly(Path path, boolean isReadOnly) throws IOException
Path
IOException
public static void setExecutable(Path path, boolean isExecutable) throws IOException
Path
IOException
public static void setAccessibleOnlyByOwner(@NotNull Path path) throws IOException
Path
from non-owners.
Note, for NTFS it removes all ACLs except owner. So if owner is not listed at ACLs then Path will become unavailable for Bamboo.IOException
public static Path resolvePathUnderParent(@NotNull Path parent, @NotNull String child)
Path.resolve(String)
. The returned path is always
in normalized and always rooted under the parent argument. Attempts to traverse out of the parent directory
will result in IllegalArgumentException being thrown.parent
- parent directorychild
- child under parent directory. Relative paths are allowed as long as the result is under the parent directoryCopyright © 2021 Atlassian Software Systems Pty Ltd. All rights reserved.