|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.rice.cs.cunit.util.FileOps
public class FileOps
File Operations.
Nested Class Summary | |
---|---|
static class |
FileOps.FileOpsTest
|
Constructor Summary | |
---|---|
FileOps()
|
Method Summary | |
---|---|
static java.lang.String |
convertToAbsolutePathEntries(java.lang.String path)
Convert all path entries in a path string to absolute paths. |
static void |
copyFile(java.io.File src,
java.io.File dst)
Copy the the file or directory src to dst. |
static java.io.File |
createTempDirectory(java.lang.String name)
Create a new temporary directory. |
static java.io.File |
createTempDirectory(java.lang.String name,
java.io.File parent)
Create a new temporary directory. |
static boolean |
deleteDirectory(java.io.File dir)
Delete the given directory including any files and directories it contains. |
static void |
deleteDirectoryOnExit(java.io.File dir)
Instructs Java to recursively delete the given directory and its contents when the JVM exits. |
static java.util.Set<java.io.File> |
enumFiles(java.io.File src)
Enumerate the files in src. |
static void |
exit(int status)
Unequivocally exits a program, if necessary by using Runtime.halt and not executing ShutdownHooks. |
static boolean |
isContainedIn(java.io.File f,
java.io.File dir)
Returns true if the file f is contained in the directory dir or its subdirectories. |
static boolean |
isContainedInCanonical(java.io.File f,
java.io.File dir)
Returns true if the file f is contained in the directory dir or its subdirectories, or if the file *is* the directory. |
static java.io.File |
makeRelativeTo(java.io.File f,
java.io.File b)
Makes a file equivalent to the given file f that is relative to base file b. |
static long |
packJar(java.io.File inDir,
java.io.File outJar)
Pack all files in the directory into the specified Jar. |
static java.lang.String[] |
splitFile(java.io.File fileToSplit)
Splits a file into an array of strings representing each parent folder of the given file. |
static java.lang.String[] |
splitPaths(java.lang.String pathString,
char pathSeparator)
Splits a string with a list of paths, separated by pathSeparator, into an array of paths. |
static java.lang.String[] |
splitPaths(java.lang.String pathString,
char pathSeparator,
boolean winDriveLetters)
Splits a string with a list of paths, separated by pathSeparator, into an array of paths. |
static long |
unpackJar(java.io.File inJar,
java.io.File outDir)
Unpack all files in the jar file to the specified directory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileOps()
Method Detail |
---|
public static java.io.File makeRelativeTo(java.io.File f, java.io.File b) throws java.io.IOException
new
File(b,makeRelativeTo(base,abs)).getCanonicalPath()
equals f.getCanonicalPath()
In
Linux/Unix, if the file f is /home/username/folder/file.java
and the file b is
/home/username/folder/sublevel/file2.java
, then the resulting File path from this method would
be ../file.java
while its canoncial path would be /home/username/folder/file.java
.
f
- The path that is to be made relative to the base fileb
- The file to make the next file relative to
getCanonicalPath()
for the returned file is the same as the result of getCanonicalPath()
for the given
file.
java.io.IOException
- if an I/O error occurs; may happen since getCanonicalFile uses the file systempublic static boolean isContainedIn(java.io.File f, java.io.File dir)
f
- the filedir
- the directory
public static boolean isContainedInCanonical(java.io.File f, java.io.File dir)
f
- the canonical filedir
- the canonical directory
public static java.lang.String[] splitFile(java.io.File fileToSplit)
/home/username/txt.txt
in linux would be split into the string array:
{"","home","username","txt.txt"}. Delimeters are excluded.
fileToSplit
- the file to split into its directories.
public static java.lang.String[] splitPaths(java.lang.String pathString, char pathSeparator)
pathString
- the string with the list of paths, separated by pathSeparatorpathSeparator
- the character separating the paths (should be either ':' or ';')
public static java.lang.String[] splitPaths(java.lang.String pathString, char pathSeparator, boolean winDriveLetters)
pathString
- the string with the list of paths, separated by pathSeparatorpathSeparator
- the character separating the paths (should be either ':' or ';')winDriveLetters
- treat "C:" followed by separatorChar as drive letter
public static void exit(int status)
status
- program's exit statuspublic static java.io.File createTempDirectory(java.lang.String name) throws java.io.IOException
name
- Non-unique portion of the name of the directory to create.
java.io.IOException
public static java.io.File createTempDirectory(java.lang.String name, java.io.File parent) throws java.io.IOException
name
- Non-unique portion of the name of the directory to create.parent
- Parent directory to contain the new directory
java.io.IOException
public static boolean deleteDirectory(java.io.File dir)
dir
- File object representing directory to delete. If, for some reason, this file object is not a
directory, it will still be deleted.
public static void deleteDirectoryOnExit(java.io.File dir)
dir
- File object representing directory to delete. If, for some reason, this file object is not a
directory, it will still be deleted.public static void copyFile(java.io.File src, java.io.File dst) throws java.io.IOException
src
- source filedst
- destination
java.io.IOException
public static java.util.Set<java.io.File> enumFiles(java.io.File src) throws java.io.IOException
src
- source file
java.io.IOException
public static java.lang.String convertToAbsolutePathEntries(java.lang.String path)
path
- path string with entries to convert
public static long unpackJar(java.io.File inJar, java.io.File outDir) throws java.io.IOException
inJar
- the input JaroutDir
- the output directory
java.io.IOException
public static long packJar(java.io.File inDir, java.io.File outJar) throws java.io.IOException
inDir
- the input directoryoutJar
- the output Jar
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |