|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.android.repository.io.FileOpUtils
public final class FileOpUtils
Some convenience methods for working with Files/FileOps.
| Method Summary | |
|---|---|
static java.io.File |
append(java.io.File base,
java.lang.String... segments)
Appends the given segments to the base file. |
static java.io.File |
append(java.lang.String base,
java.lang.String... segments)
Appends the given segments to the base file. |
static FileOp |
create()
The standard way to create a FileOp that interacts with the real filesystem. |
static java.io.File |
getNewTempDir(java.lang.String base,
FileOp fileOp)
Creates a new subdirectory of the system temp directory. |
static java.lang.String |
makeRelative(java.io.File baseDir,
java.io.File toBeRelative,
FileOp fop)
Computes a relative path from "toBeRelative" relative to "baseDir". |
static void |
recursiveCopy(java.io.File src,
java.io.File dest,
FileOp fop)
Copies a file or directory tree to the given location. |
static void |
safeRecursiveOverwrite(java.io.File src,
java.io.File dest,
FileOp fop,
ProgressIndicator progress)
Moves a file or directory from one location to another. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
@NonNull public static FileOp create()
FileOp that interacts with the real filesystem.
public static void recursiveCopy(@NonNull
java.io.File src,
@NonNull
java.io.File dest,
@NonNull
FileOp fop)
throws java.io.IOException
dest should not exist: with
the file system currently looking like
/
dir1/
a.txt
dir2/
Running recursiveCopy(new File("/dir1"), new File("/dir2"), fOp) will result in an
exception, while recursiveCopy(new File("/dir1"), new File("/dir2/foo") will result
in
/
dir1/
a.txt
dir2/
foo/
a.txt
This is equivalent to the behavior of cp -r when the target does not exist.
src - File to copydest - Destination.fop - The FileOp to use for file operations.
java.io.IOException - If the destination already exists, or if there is a problem copying the
files or creating directories.
public static void safeRecursiveOverwrite(@NonNull
java.io.File src,
@NonNull
java.io.File dest,
@NonNull
FileOp fop,
@NonNull
ProgressIndicator progress)
throws java.io.IOException
src - File to movedest - Destination. Follows the same rules as recursiveCopy(File, File,
FileOp)}.fop - The FileOp to use for file operations.progress - Currently only used for error logging.
java.io.IOException - If some problem occurs during copies or directory creation.
@Nullable
public static java.io.File getNewTempDir(@NonNull
java.lang.String base,
@NonNull
FileOp fileOp)
<base> + NN, where NN makes the directory distinct from any existing directories.
@NonNull
public static java.io.File append(@NonNull
java.io.File base,
@NonNull
java.lang.String... segments)
segments to the base file.
base - A base file, non-null.segments - Individual folder or filename segments to append to the base file.
@NonNull
public static java.io.File append(@NonNull
java.lang.String base,
@NonNull
java.lang.String... segments)
segments to the base file.
base - A base file path, non-empty and non-null.segments - Individual folder or filename segments to append to the base path.
@NonNull
public static java.lang.String makeRelative(@NonNull
java.io.File baseDir,
@NonNull
java.io.File toBeRelative,
FileOp fop)
throws java.io.IOException
baseDir - The base directory to be relative to.toBeRelative - The file or directory to make relative to the base.fop - FileOp, in this case just to determine the platform.
java.io.IOException - If drive letters don't match on Windows or path canonicalization fails.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||