public class FileUtils extends Object
Modifier and Type | Field and Description |
---|---|
static File |
BIT_BUCKET
Bit bucket.
|
static File |
CWD
Current working directory.
|
static File |
ROOT
Root directory of the file system.
|
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
chmod(Path path,
int mode)
Set file permissions, just like chmod(2).
|
static Path |
createAnonymousSymlink(Path target)
Create a temporary symbolic link pointing to specified target path.
|
static Path |
followSymlink(Path path)
Follow every symlink in every component of given file recursively, just like
readlink -f does. |
static File |
getCwd()
Return process current working directory.
|
static void |
linkOrCopy(Path source,
Path target)
Create hard link or copy file if creating hard link is not possible.
|
static void |
replaceFileWithSymlink(Path file,
Path target)
Try to atomically replace regular file with a symbolic link.
|
public static final File CWD
public static final File ROOT
public static final File BIT_BUCKET
public static Path followSymlink(Path path)
readlink -f
does.file
- path in which symlinks are to be followedpublic static File getCwd()
public static void linkOrCopy(Path source, Path target) throws IOException
source
- source filetarget
- link target or destination fileIOException
- if any I/O exception occurspublic static Path createAnonymousSymlink(Path target) throws IOException
target
- target of the symbolic linkIOException
- if any I/O exception occurspublic static void chmod(Path path, int mode) throws IOException
path
- path to file to change permissions ofmode
- permissions in integer formatIOException
- if an I/O exception occurspublic static void replaceFileWithSymlink(Path file, Path target) throws IOException
file
- file to be replacedtarget
- symbolic link targetIOException
- if an I/O exception occursCopyright © 2012–2015 Red Hat, Inc.. All rights reserved.