public class FileOperationsWorker.FileOps
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String[] |
proPath
This is the list of paths where progress file can be found.
|
Constructor and Description |
---|
FileOps() |
Modifier and Type | Method and Description |
---|---|
boolean |
copyFile(java.lang.String source,
java.lang.String target,
boolean relative,
boolean overwrite)
Copy an arbitrary source file to a given target file.
|
boolean |
deleteFile(java.lang.String filename,
boolean relative)
Delete an arbitrary file specified by a filename which can be either
absolute or relative to the current directory or relative to the
project home directory.
|
boolean |
exists(java.lang.String filename,
boolean relative)
Determine if a filesystem name references an existing filesystem
object.
|
java.lang.String |
findFile(java.lang.String filename)
Finds a filename within the configured PROPATH.
|
java.util.Iterator<java.lang.String> |
findFiles(java.lang.String filename)
Finds all filenames within the configured
PROPATH . |
java.io.File |
getFile(java.lang.String filename,
boolean relative)
Creates and returns a file object for a filename which can be
specified as either absolute or relative to the current directory OR
relative to the project home directory.
|
java.lang.String |
getFileSep()
Get the platform-specific file separator string for the current
platform.
|
java.lang.String |
getPathSep()
Get the platform-specific path separator string for the current
platform.
|
boolean |
isDirectory(java.lang.String filename,
boolean relative)
Determine if a filename references a directory (and not a file).
|
boolean |
isFile(java.lang.String filename,
boolean relative)
Determine if a filename references a file (and not a directory).
|
boolean |
renameFile(java.lang.String source,
java.lang.String target,
boolean relative)
Rename an arbitrary file to a new name, which can (on some platforms)
be used to move a file.
|
private java.lang.String[] proPath
public boolean isFile(java.lang.String filename, boolean relative) throws ConfigurationException, java.io.IOException
filename
- The file to check.relative
- true
if the filename is relative to the
project home directory, false
if the filename
is absolute or relative to the current directory.true
if the filename references a file,
else false
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.java.io.IOException
- if there was an I/O error accessing the file system.public boolean isDirectory(java.lang.String filename, boolean relative) throws ConfigurationException, java.io.IOException
filename
- The file to check.relative
- true
if the filename is relative to the
project home directory, false
if the filename
is absolute or relative to the current directory.true
if the filename references a directory,
else false
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.java.io.IOException
- if there was an I/O error accessing the file system.public boolean exists(java.lang.String filename, boolean relative) throws ConfigurationException, java.io.IOException
filename
- The file to check.relative
- true
if the filename is relative to the
project home directory, false
if the filename
is absolute or relative to the current directory.true
if the filename exists, else
false
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.java.io.IOException
- if there was an I/O error accessing the file system.public boolean deleteFile(java.lang.String filename, boolean relative) throws ConfigurationException, java.io.IOException
filename
- The file to delete.relative
- true
if the filename is relative to the
project home directory, false
if the filename
is absolute or relative to the current directory.true
if the file was successfully deleted,
else false
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.java.io.IOException
- if there was an I/O error deleting the file.public boolean renameFile(java.lang.String source, java.lang.String target, boolean relative) throws ConfigurationException, java.io.IOException
source
- The source filename.target
- The target filename.relative
- true
if BOTH filenames are relative to the
project home directory, false
if BOTH filenames
are either absolute or relative to the current directory.true
if the file was successfully renamed,
else false
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.java.io.IOException
- if there was an I/O error while renaming the file.public boolean copyFile(java.lang.String source, java.lang.String target, boolean relative, boolean overwrite) throws ConfigurationException, java.io.IOException
source
- The source filename.target
- The target filename.relative
- true
if BOTH filenames are relative to the
project home directory, false
if BOTH filenames
are either absolute or relative to the current directory.overwrite
- true
to overwrite the target if it exists,
false
to abort the copy if the target exists.true
if the file was successfully copied,
else false
(includes the non-overwrite case
where the target already exists).ConfigurationException
- if P2J_HOME
has not been defined for this process.java.io.IOException
- if there was an I/O error deleting the file.public java.lang.String getFileSep()
public java.lang.String getPathSep()
public java.io.File getFile(java.lang.String filename, boolean relative) throws ConfigurationException, java.io.IOException
filename
- The file's name.relative
- true
if the filenames are relative to the
project home directory, false
if the filenames
are either absolute or relative to the current directory.ConfigurationException
- if P2J_HOME
has not been defined for this
process.java.io.IOException
- if there was an I/O error deleting the file.public java.lang.String findFile(java.lang.String filename) throws ConfigurationException
Configuration
, which is backed-up by p2j.cfg.xml.filename
- The filename that will be searched in the PROPATH.null
is returned.ConfigurationException
- if P2J_HOME
has not been defined for this process.public java.util.Iterator<java.lang.String> findFiles(java.lang.String filename) throws ConfigurationException
PROPATH
. All needed information are
read from Configuration
, which is backed-up by p2j.cfg.xml
.filename
- The filename that will be searched in the PROPATH
.null
is returned.ConfigurationException
- if P2J_HOME
has not been defined for this process.