|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ptc.windchill.structconf.util.FileUtil
Some file utilities.
Nested Class Summary | |
static class |
FileUtil.FileInfo
Snapshot of a files information useful for comparing. |
Field Summary | |
private static DecimalFormat |
format__
|
Constructor Summary | |
private |
FileUtil()
Defined private to prevent it from showing up in the javadoc. |
Method Summary | |
static FileUtil.FileInfo |
backup(File file)
Backup the file into the file's current directory renaming it by inserting a right-justified, zero-padded three digit number extension before the extension, if one exists. |
static FileUtil.FileInfo |
backup(File file,
File backup_directory)
Backup by copying contents of the file into the backup directory and inserting a right-justified, zero-padded three digit number extension before the extension, if one exists. |
static FileUtil.FileInfo |
backup(File file,
File backup_directory,
int forced_backup_number,
int[] out_param_number)
Backup by copying contents of the file into the backup directory and inserting a right-justified, zero-padded three digit number extension before the extension, if one exists. |
static File |
canonicalize(File file)
Convert the file to its canonical form if possible. |
static boolean |
cleanupIdenticalBackup(FileUtil.FileInfo file_info,
FileUtil.FileInfo backup_file_info)
Removes the file described by backup_file_info if it exists and is identical
in size and CRC to the file described by file_info . |
static long |
copy(File from_file,
File to_file)
Copy from_file to to_file and return the CRC32-based CRC of the file that was copied. |
static long |
crc32(File file)
Compute the CRC-32 checksum for the specified file. |
static File |
directoryFromPath(String directory_path)
Convert the string to a File object with error checking. |
private static File |
genFileFor(File backup_directory,
String base_file_name,
String extension,
int index)
|
private static String |
relativize(ArrayList directory_parts,
ArrayList file_parts)
|
static String |
relativize(File directory,
File file)
Equivalent of relativize(directory, file, false) . |
static String |
relativize(File directory,
File file,
boolean null_if_not_relativized)
Returns a String path to file defined as a subdirectory relative to the directory . |
private static ArrayList |
toParts(File file)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static DecimalFormat format__
Constructor Detail |
private FileUtil()
Method Detail |
public static FileUtil.FileInfo backup(File file) throws IOException
IOException
- if the file couldn't be renamed to its backuppublic static FileUtil.FileInfo backup(File file, File backup_directory) throws IOException
IOException
- if the file couldn't be renamed to its backuppublic static FileUtil.FileInfo backup(File file, File backup_directory, int forced_backup_number, int[] out_param_number) throws IOException
forced_backup_number
- if >= zero, then this number will be used instead of finding the next free numberout_param_number
- if not-null and length >= 1, then the number of the backup file will be placed into this out_param_number[0]
IOException
- if the file couldn't be renamed to its backupprivate static File genFileFor(File backup_directory, String base_file_name, String extension, int index)
public static long copy(File from_file, File to_file) throws IOException
from_file
to to_file
and return the CRC32-based CRC of the file that was copied.
IOException
public static boolean cleanupIdenticalBackup(FileUtil.FileInfo file_info, FileUtil.FileInfo backup_file_info)
backup_file_info
if it exists and is identical
in size and CRC to the file described by file_info
.
public static long crc32(File file) throws IOException
IOException
- if there's a problem reading the specified file.public static File canonicalize(File file)
public static String relativize(File directory, File file, boolean null_if_not_relativized)
file
defined as a subdirectory relative to the directory
.
It will first try to get the relative paths using the files as given, but if
this fails, it will canonicalize both the directy and file and then try
again.
null_if_not_relativized==true
and file.toString()
otherwisepublic static String relativize(File directory, File file)
relativize(directory, file, false)
.
private static String relativize(ArrayList directory_parts, ArrayList file_parts)
private static ArrayList toParts(File file)
public static File directoryFromPath(String directory_path) throws IOException
IOException
- if the directory doesn't exist or the path does not refer to a directory
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |