|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.bamboo.util.BambooFileUtils
public class BambooFileUtils
Method Summary | |
---|---|
static boolean |
contains(java.io.File file,
java.util.regex.Pattern pattern)
This method checks whether given pattern occurs in a file. |
static boolean |
containsRegex(java.io.File file,
java.lang.String regexToMatch)
Convenience method. |
static java.io.File |
createTempDirectory(java.io.File parentDir,
java.lang.String prefix)
Create a temporary directory in specified location. |
static java.io.File |
createTempDirectory(java.lang.Object client)
|
static java.io.File |
createTempDirectory(java.lang.String prefix)
|
static boolean |
isDirectoryImportant(java.io.File planSourceDirectory)
Checks a path against a defined list of directories to see if it is important (and should not be deleted) |
protected static java.io.File |
openSafeTempFile(java.lang.String prefix,
java.lang.String suffix,
java.io.File directory)
Creates a temporary file readable and writable only by the owner (if supported by the platform). |
static java.lang.String |
pathFromComponents(java.lang.String[] pathComponents)
|
static java.lang.String |
relativizePath(java.io.File rootDirectory,
java.io.File workingDirectory,
java.lang.String path)
Given parent and child directories, and a path relative to parent directory, return path relative to the child directory. |
static void |
renameTo(java.io.File from,
java.io.File to)
Renames a file or directory. |
static java.io.File |
safeWriteStringToFile(java.lang.String string,
java.lang.String prefix,
java.lang.String suffix,
java.io.File directory)
Writes a string to a newly created temporary file in as safe manner as possible. |
static boolean |
setReadableByOwnerOnly(java.io.File file)
Sets the file permissions so that only the owner can read from a file |
static boolean |
setWritableByOwnerOnly(java.io.File file)
Sets the file permissions so that only the owner can write to a file |
static java.util.List<java.lang.String> |
splitPathToComponents(java.lang.String path)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean isDirectoryImportant(java.io.File planSourceDirectory)
planSourceDirectory
-
public static java.io.File createTempDirectory(@NotNull java.lang.Object client) throws java.io.IOException
java.io.IOException
public static java.io.File createTempDirectory(@Nullable java.io.File parentDir, @NotNull java.lang.String prefix) throws java.io.IOException
parentDir
- null indicates default tmp directoryprefix
- filename prefix
java.io.IOException
public static java.io.File createTempDirectory(@NotNull java.lang.String prefix) throws java.io.IOException
java.io.IOException
@NotNull protected static java.io.File openSafeTempFile(@NotNull java.lang.String prefix, @Nullable java.lang.String suffix, @Nullable java.io.File directory) throws java.io.IOException
java.io.IOException
File.createTempFile()
public static boolean setWritableByOwnerOnly(java.io.File file)
file
-
public static boolean setReadableByOwnerOnly(java.io.File file)
file
-
@NotNull public static java.io.File safeWriteStringToFile(@NotNull java.lang.String string, @NotNull java.lang.String prefix, @Nullable java.lang.String suffix, @Nullable java.io.File directory) throws java.io.IOException
string
- the string to write
java.io.IOException
File.createTempFile()
@NotNull public static java.util.List<java.lang.String> splitPathToComponents(@NotNull java.lang.String path)
@NotNull public static java.lang.String pathFromComponents(@NotNull java.lang.String[] pathComponents)
public static boolean contains(java.io.File file, java.util.regex.Pattern pattern) throws java.io.IOException
file
- the file to checkpattern
- the pattern to search for
java.io.IOException
- in case of file access problemspublic static boolean containsRegex(@NotNull java.io.File file, @NotNull java.lang.String regexToMatch) throws java.io.IOException
java.io.IOException
contains(File, Pattern)
public static java.lang.String relativizePath(@NotNull java.io.File rootDirectory, @NotNull java.io.File workingDirectory, @Nullable java.lang.String path)
rootDirectory
- root directoryworkingDirectory
- working directory (must be inside root directory)path
- path relative to root directory
public static void renameTo(java.io.File from, java.io.File to) throws java.io.IOException
from
- the source file/directoryto
- the new location of source file
java.io.IOException
- if the destination file/directory already exists or move operation fails for other reason
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |