Interface FileService
-
- All Superinterfaces:
Service
public interface FileService extends Service
This class provides the ability to manipulate and query files, directories, and partitions at runtime. It is used, for example, by files beans, file-system bean conditions, ASCII file update beans, the Destination wizard panel, etc.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFERRED
The constant used with deleteFile when delete is deferred.static int
DIRECTORIES
Indicates what type of files to return to the getDirectoryList() method.static java.lang.String
FAT16
The constant used with getPartitionFormat for FAT16 partitions.static java.lang.String
FAT32
The constant used with getPartitionFormat for FAT32 partitions.static int
FILES
Indicates what type of files to return to the getDirectoryList() method.static int
FILES_AND_DIRECTORIES
static int
FIXED
The constant used with getPartitionType for FIXED partitions.static java.lang.String
HOME_DIR
The constant used with getNamedDirectory to return the directory for home files.static java.lang.String
HPFS
The constant used with getPartitionFormat for HPFS partitions.static java.lang.String
HPFS386
The constant used with getPartitionFormat for HPFS partitions.static java.lang.String
INSTALL_DIR
The constant used with getNamedDirectory to return the root directory for the program files on the system.static java.lang.String
JFS
The constant used with getpartitionFormat for JFS partitions.static java.lang.String
LIB_DIR
The constant used with getNamedDirectory to return the directory for the library files on the system.static java.lang.String
LOG_DIR
The constant used with getNamedDirectory to return the directory for writing log files.static java.lang.String
NAME
static java.lang.String
NTFS
The constant used with getPartitionFormat for NTFS partitions.static int
REMOVABLE
The constant used with getPartitionType for REMOVABLE partitions.static int
SUCCESS
The constant used with deleteFile when delete succeeds.static java.lang.String
TEMP_DIR
The constant used with getNamedDirectory to return the directory for writing temporary files.static java.lang.String
TIMESTAMP
The constant used with getNamedDirectory to return a filename fragment generated using the current time.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
appendBinaryFile(java.lang.String fileName, byte[] content)
Appends bytes to a binary file.void
appendToAsciiFile(java.lang.String fileName, java.lang.String[] content)
Appends lines to an ASCII file.long
calculateDirectorySize(java.lang.String dirName)
Calculates the size of a given directory recursively and returns the total size (in bytes).boolean
canRead(java.lang.String file)
This method is useful to developers when creating a custom bean.boolean
comparePaths(java.lang.String path1, java.lang.String path2)
Verifies whether or not two paths are the same, taking into account multiple path separators and folder relocators within the path (such as "/." and "/..").void
copyDirectory(java.lang.String source, java.lang.String target, boolean copySubDirectories, boolean overwrite)
This method is useful to developers when creating a custom bean.int
copyFile(java.lang.String sourceFileName, java.lang.String destinationFileName, boolean overwrite)
This method is useful to developers when creating a custom bean.void
createAsciiFile(java.lang.String fileName, java.lang.String[] content)
This method is useful to developers when creating a custom bean.void
createAsciiFile(java.lang.String fileName, java.lang.String[] content, java.lang.String fileEncoding)
This method is useful to developers when creating a custom bean.void
createBinaryFile(java.lang.String fileName, byte[] content)
This method is useful to developers when creating a custom bean.void
createDirectory(java.lang.String directoryName)
Creates a directory on the target system.java.lang.String[]
createDirectoryReturnNew(java.lang.String directoryName)
This method is useful to developers when creating a custom bean.java.lang.String
createFileName(java.lang.String context, java.lang.String fileName)
This method is useful to developers when creating a custom bean.void
createSymbolicLink(java.lang.String target, java.lang.String linkName, boolean forceLink)
This method is used to create a symbolic link on unix based platforms.int
deleteDirectory(java.lang.String directory)
This method is useful to developers when creating a custom bean.int
deleteDirectory(java.lang.String directory, boolean ifEmpty, boolean includeSubDirs)
This method is useful to developers when creating a custom bean.int
deleteFile(java.lang.String fileName)
This method is useful to developers when creating a custom bean.boolean
fileExists(java.lang.String fileName)
This method is useful to developers when creating a custom bean.java.lang.String
formatSizeAsBytes(long bytes)
Formats the specified number of bytes as a human-readable string.int
getAsciiFileLineCount(java.lang.String fileName)
Returns the number of lines in an ASCII file.java.lang.String[]
getDirectoryList(java.lang.String dir, int type)
Gets a list of files in a directory.FileAttributes
getFileAttributes(java.lang.String file)
This method is useful to developers when creating a custom bean.java.lang.String
getFileOwner(java.lang.String file)
Gets a file's owner.java.lang.String
getFileOwnerGroup(java.lang.String file)
Gets a file's owner group.int
getFileSize(java.lang.String fileName)
Returns the size of an a file (in bytes).java.lang.String
getName(java.lang.String pathName)
Gets the name portion of the supplied path name.java.lang.String
getNamedDirectory(java.lang.String directoryName)
Returns the directory for the specified type.java.lang.String
getParent(java.lang.String child)
Returns the parent directory of the specified directory.java.lang.String
getPartitionFormat(java.lang.String partition)
This method is useful to developers when creating a custom bean.long
getPartitionFreeSpace(java.lang.String partitionName)
This method is useful to developers when creating a custom bean.long
getPartitionFreeSpace(java.lang.String partitionName, long requiredBytes)
This method is useful to developers when creating a custom bean.java.lang.String
getPartitionName(java.lang.String absolutePath, java.lang.String[] partitionNames)
Maps the specified path into a valid partition out of a list of partition names.java.lang.String
getPartitionName(java.lang.String absolutePath, java.lang.String[] partitionNames, java.lang.String defaultPartition)
Maps the specified path into a valid partition out of a list of partition names.java.lang.String[]
getPartitionNames()
This method is useful to developers when creating a custom bean.int
getPartitionType(java.lang.String directory)
This method is useful to developers when creating a custom bean.java.lang.String
getPathSeparator()
Gets the path separator for the file system this service is executing on.char
getPathSeparatorChar()
Gets the path separator character for the file system this service is executing on.java.lang.String
getPlatformId()
NOTE : This API is for internal use.java.lang.String
getSeparator()
Returns the separator for the file system on which this service is executing.char
getSeparatorChar()
Returns the separator character for the file system on which this service is executing.int
getSystemUMask()
Returns the umask setting for the current process.boolean
isAbsolute(java.lang.String fileName)
This method is useful to developers when creating a custom bean.boolean
isDirectory(java.lang.String file)
This method is useful to developers when creating a custom bean.boolean
isDirectoryWritable(java.lang.String directory)
This method is useful to developers when creating a custom bean.boolean
isFile(java.lang.String file)
This method is useful to developers when creating a custom bean.int
moveFile(java.lang.String sourceFileName, java.lang.String destinationFileName, boolean overwrite)
This method is useful to developers when creating a custom bean.java.lang.String
normalizeFileName(java.lang.String fileName)
This method is useful to developers when creating a custom bean.java.lang.String
normalizeFileName(java.lang.String fileName, char normalSeparator)
This method is useful to developers when creating a custom bean.java.lang.String[]
readAsciiFile(java.lang.String fileName)
Returns all of the lines of an ASCII file.java.lang.String[]
readAsciiFile(java.lang.String fileName, java.lang.String fileEncoding)
Returns all of the lines of an ASCII file.int
readAsciiFile(java.lang.String fileName, java.lang.String[] linesRead, int start, int number)
Reads lines in an ASCII file, starting at a specified line, and reading a specified number of lines.int
readBinaryFile(java.lang.String fileName, byte[] bytesRead, int start, int number)
Reads bytes in a binary file, starting at a specified offset, and reading a specified number of bytes.void
removeSymbolicLink(java.lang.String linkName)
This method is used to remove a symbolic link on unix based platforms.void
setFileAttributes(java.lang.String file, FileAttributes attributes)
Sets the attributes of the specified file.void
setFileCreated(java.lang.String fileName, long date)
Changes the created date for the specified file.void
setFileExecutable(java.lang.String file)
Sets the attributes of the specified file to be an executable.void
setFileModified(java.lang.String fileName, long date)
This method is useful to developers when creating a custom bean.void
setFileOwner(java.lang.String file, java.lang.String userid)
Sets a file's owner.void
setFileOwnerGroup(java.lang.String file, java.lang.String groupid)
Sets a file's owner group.void
setFileTimes(java.lang.String fileName, long creationDate, long accessDate, long writeDate)
Changes the dates for the specified file.void
setSystemUMask(int mode)
Modifies the system umask for the current process.boolean
supportsLongFileNames(java.lang.String partition)
This method is useful to developers when creating a custom bean.void
updateAsciiFile(java.lang.String fileName, java.lang.String[] lines, int start)
Updates the lines in an ASCII file starting at and including the specified line.void
updateBinaryFile(java.lang.String fileName, byte[] bytes, int start)
Updates the bytes in a binary file starting at and including the specified offset.void
validateFileName(java.lang.String fileName)
Validates the specified file name.-
Methods inherited from interface com.installshield.wizard.service.Service
cancelOperation, getName, getOperationProgress, getServiceImplementorType, isNoopMode, isOperationCanceled, isOperationEnded, isOperationSuspended, resumeOperation, setNoopMode, suspendOperation
-
-
-
-
Field Detail
-
NAME
static final java.lang.String NAME
-
FILES
static final int FILES
Indicates what type of files to return to the getDirectoryList() method.- See Also:
- Constant Field Values
-
DIRECTORIES
static final int DIRECTORIES
Indicates what type of files to return to the getDirectoryList() method.- See Also:
- Constant Field Values
-
FILES_AND_DIRECTORIES
static final int FILES_AND_DIRECTORIES
- See Also:
- Constant Field Values
-
INSTALL_DIR
static final java.lang.String INSTALL_DIR
The constant used with getNamedDirectory to return the root directory for the program files on the system.- See Also:
- Constant Field Values
-
LIB_DIR
static final java.lang.String LIB_DIR
The constant used with getNamedDirectory to return the directory for the library files on the system.- See Also:
- Constant Field Values
-
TEMP_DIR
static final java.lang.String TEMP_DIR
The constant used with getNamedDirectory to return the directory for writing temporary files.- See Also:
- Constant Field Values
-
LOG_DIR
static final java.lang.String LOG_DIR
The constant used with getNamedDirectory to return the directory for writing log files.- See Also:
- Constant Field Values
-
TIMESTAMP
static final java.lang.String TIMESTAMP
The constant used with getNamedDirectory to return a filename fragment generated using the current time. This is useful for creating a unique file name, e.g.,
./ .log - See Also:
- Constant Field Values
-
HOME_DIR
static final java.lang.String HOME_DIR
The constant used with getNamedDirectory to return the directory for home files.- See Also:
- Constant Field Values
-
FAT16
static final java.lang.String FAT16
The constant used with getPartitionFormat for FAT16 partitions.- See Also:
- Constant Field Values
-
NTFS
static final java.lang.String NTFS
The constant used with getPartitionFormat for NTFS partitions.- See Also:
- Constant Field Values
-
HPFS
static final java.lang.String HPFS
The constant used with getPartitionFormat for HPFS partitions.- See Also:
- Constant Field Values
-
HPFS386
static final java.lang.String HPFS386
The constant used with getPartitionFormat for HPFS partitions.- See Also:
- Constant Field Values
-
JFS
static final java.lang.String JFS
The constant used with getpartitionFormat for JFS partitions.- See Also:
- Constant Field Values
-
FAT32
static final java.lang.String FAT32
The constant used with getPartitionFormat for FAT32 partitions.- See Also:
- Constant Field Values
-
FIXED
static final int FIXED
The constant used with getPartitionType for FIXED partitions.- See Also:
- Constant Field Values
-
REMOVABLE
static final int REMOVABLE
The constant used with getPartitionType for REMOVABLE partitions.- See Also:
- Constant Field Values
-
SUCCESS
static final int SUCCESS
The constant used with deleteFile when delete succeeds.- See Also:
- Constant Field Values
-
DEFERRED
static final int DEFERRED
The constant used with deleteFile when delete is deferred.- See Also:
- Constant Field Values
-
-
Method Detail
-
deleteFile
int deleteFile(java.lang.String fileName) throws ServiceException
This method is useful to developers when creating a custom bean. Deletes the specified file from the target system.- Returns:
- SUCCESS if the operation was carried out immediately, or DEFERRED if the operation will be carried out later when the specified file is no longer locked.
- Throws:
ServiceException
- if an error occurred during the operation.
-
deleteDirectory
int deleteDirectory(java.lang.String directory) throws ServiceException
This method is useful to developers when creating a custom bean. Performs the safe deletion of a directory -- The directory is only deleted if it empty. (Note: This method calls the alternate form of deleteDirectory using the appropriate parameters for safeguarding non-empty directories.)- Returns:
- SUCCESS if the operation was carried out immediately, or DEFERRED if the operation will be carried out later when the specified directory is no longer locked.
- Throws:
ServiceException
-
deleteDirectory
int deleteDirectory(java.lang.String directory, boolean ifEmpty, boolean includeSubDirs) throws ServiceException
This method is useful to developers when creating a custom bean. Removes the specified directory according to the following table:ifEmpty includeSubDirs result true true Delete all empty directories in specified directory tree, including the specified directory if it is empty, after processing its subdirectories. true false Delete only specified directory if empty. false true Delete specified directory tree no matter what. Any files or directories in use should be deleted at a later time when they have been unlocked. false false Delete all files in the specified directory only . Remove the directory itself if it is empty after removing the files. Files in use should be deleted at a later time when they have been unlocked. - Parameters:
directory
- The fully qualified directory name to delete.ifEmpty
- If "true", only empty directories are deleted.includeSubdirs
- A flag indicating whether or not subdirectories should also be deleted. If the value is "true", the ifEmpty flag applies to each directory that was considered for deletion.- Returns:
- SUCCESS if the operation was carried out immediately, or DEFERRED if the operation will be carried out later when the specified file is no longer locked.
- Throws:
ServiceException
- if an error occurred during the operation.
-
createDirectory
void createDirectory(java.lang.String directoryName) throws ServiceException
Creates a directory on the target system. This method is useful to developers when creating a custom bean.- Throws:
ServiceException
- if an error occurred during the operation
-
createDirectoryReturnNew
java.lang.String[] createDirectoryReturnNew(java.lang.String directoryName) throws ServiceException
This method is useful to developers when creating a custom bean. Creates a directory on the target system and returns a String array containing each directory that was created. Each element in the array is an absolute path, and parent directories preceed child directories.For example, if you call this method passing "/home/myself/subdir1/subdir2", and "/home/myself" already exists, but "/home/myself/subdir1" does not exist, this method will return an array containing:
- /home/myself/subdir1
- /home/myself/subdir1/subdir2
- Parameters:
directoryName
- The name of the directory to create.- Returns:
- A String array indicating the directories created during this procedure.
- Throws:
ServiceException
- if an error occurred during the operation
-
setFileTimes
void setFileTimes(java.lang.String fileName, long creationDate, long accessDate, long writeDate) throws ServiceException
Changes the dates for the specified file.- Throws:
ServiceException
- if an error occurred during the operation
-
setFileCreated
void setFileCreated(java.lang.String fileName, long date) throws ServiceException
Changes the created date for the specified file. This method is useful to developers when creating a custom bean.- Throws:
ServiceException
- if an error occurred during the operation
-
setFileModified
void setFileModified(java.lang.String fileName, long date) throws ServiceException
This method is useful to developers when creating a custom bean. Sets the date the file was last modified.- Throws:
ServiceException
- if an error occurred during the operation
-
fileExists
boolean fileExists(java.lang.String fileName) throws ServiceException
This method is useful to developers when creating a custom bean. Returns "true" if the specified file or directory exists on the target system; otherwise, "false".- Throws:
ServiceException
- if an error occurred during the operation.
-
isDirectory
boolean isDirectory(java.lang.String file) throws ServiceException
This method is useful to developers when creating a custom bean. Returns "true" is the specified file is a directory; otherwise, returns "false".- Parameters:
file
- The name of the file to examine- Returns:
- true if the file exists and is a directory, false otherwise
- Throws:
ServiceException
- if an error occurred during the operation.
-
isFile
boolean isFile(java.lang.String file) throws ServiceException
This method is useful to developers when creating a custom bean. Determines whether the specified file is a file.- Parameters:
file
- The pathname to the file or directory to check. The path can be relative or absolute.- Returns:
- true if the file exists and is a file, false otherwise
- Throws:
ServiceException
- if an error occurred during the operation.
-
canRead
boolean canRead(java.lang.String file) throws ServiceException
This method is useful to developers when creating a custom bean. Returns "true" if the specified file can be read by the current process; otherwise, returns "false".- Throws:
ServiceException
- if an error occurred during the operation.
-
getSeparator
java.lang.String getSeparator() throws ServiceException
Returns the separator for the file system on which this service is executing.- Returns:
- The separator for the file system this service is executing on.
- Throws:
ServiceException
- if an error occurred during the operation.
-
getSeparatorChar
char getSeparatorChar() throws ServiceException
Returns the separator character for the file system on which this service is executing.- Returns:
- The separator character for the file system this service is executing on.
- Throws:
ServiceException
- if an error occurred during the operation.
-
getPathSeparator
java.lang.String getPathSeparator() throws ServiceException
Gets the path separator for the file system this service is executing on.- Returns:
- The path separator for the file system this service is executing on.
- Throws:
ServiceException
- if an error occurred during the operation.
-
getPathSeparatorChar
char getPathSeparatorChar() throws ServiceException
Gets the path separator character for the file system this service is executing on.- Returns:
- The path separator character for the file system this service is executing on.
- Throws:
ServiceException
- if an error occurred during the operation.
-
getDirectoryList
java.lang.String[] getDirectoryList(java.lang.String dir, int type) throws ServiceException
Gets a list of files in a directory.- Parameters:
dir
- The directory of which to get a listing.type
- The type of the returned list.- Returns:
- The list of files in the directory, or "null" if the directory does not exist, is not a directory, or is not readable.
- Throws:
ServiceException
- if an error occurred during the operation.
-
getParent
java.lang.String getParent(java.lang.String child) throws ServiceException
Returns the parent directory of the specified directory.- Parameters:
child
- The directory to get the parent of; is the same directory if "child" is the root directory.- Throws:
ServiceException
-
getName
java.lang.String getName(java.lang.String pathName) throws ServiceException
Gets the name portion of the supplied path name. The returned name will generally be the string following the last path separator in the supplied path name.- Parameters:
pathName
- The path name (can be an absolute or relative path) whose name is to be determined.- Returns:
- The name associated with the supplied path name.
- Throws:
ServiceException
- if an error occurred during the operation.
-
formatSizeAsBytes
java.lang.String formatSizeAsBytes(long bytes) throws ServiceException
Formats the specified number of bytes as a human-readable string.- Parameters:
bytes
- The number of bytes to format.- Returns:
- - A human-readable representation of the number of bytes.
- Throws:
ServiceException
- if an error occurred during the operation.
-
copyFile
int copyFile(java.lang.String sourceFileName, java.lang.String destinationFileName, boolean overwrite) throws ServiceException
This method is useful to developers when creating a custom bean. Copies one file to another.- Parameters:
sourceFileName
- The source file path.destinationFileName
- The destination file path.overwrite
- If "true" and the destination file exists, will be overwritten with the source. If "false" and the destination file exists, an exception is thrown.- Returns:
- SUCCESS if the operation was carried out immediately, or DEFERRED if the operation will be carried out later when the specified file is no longer locked.
- Throws:
ServiceException
- if an error occurred during the operation
-
moveFile
int moveFile(java.lang.String sourceFileName, java.lang.String destinationFileName, boolean overwrite) throws ServiceException
This method is useful to developers when creating a custom bean. Moves a file from one location to another.- Parameters:
sourceFileName
- The source file path. This must be a fully qualified file name.destinationFileName
- The destination file path. This must be a fully qualified file name.overwrite
- If "true" and the destination file exists, will be overwritten with the source. If "false" and the destination file exists, an exception is thrown.- Returns:
- SUCCESS if the operation was carried out immediately, or DEFERRED if the operation will be carried out later when the specified file is no longer locked.
- Throws:
ServiceException
- if an error occurred during the operation
-
getNamedDirectory
java.lang.String getNamedDirectory(java.lang.String directoryName) throws ServiceException
Returns the directory for the specified type. See the "XXX_DIR" fields in the Javadoc API for each specific Platform for a list of the supported named directories.- Parameters:
directoryName
- the directory type name.- Throws:
ServiceException
- if the specified type is not supported by the service, or if an error occurred during the operation.ServiceException
- if an error occurred during the operation
-
getPartitionNames
java.lang.String[] getPartitionNames() throws ServiceException
This method is useful to developers when creating a custom bean. Returns an array of Strings representing all partition names.- Returns:
- The list of partition names.
- Throws:
ServiceException
- if an error occurred during the operation.
-
getPartitionName
java.lang.String getPartitionName(java.lang.String absolutePath, java.lang.String[] partitionNames) throws ServiceException
Maps the specified path into a valid partition out of a list of partition names. If the specified path cannot be mapped into a valid partition, it returns the absolute path itself. For example, given the list of partitions:- /
- /tmp
- /home
- /proc
- Parameters:
absolutePath
- The path whose partition match is being queried.partitioNames
- The list of partition names to query for the path match.- Returns:
- Returns the string indicating the partition determined as the match for the given path.
- Throws:
ServiceException
-
getPartitionName
java.lang.String getPartitionName(java.lang.String absolutePath, java.lang.String[] partitionNames, java.lang.String defaultPartition) throws ServiceException
Maps the specified path into a valid partition out of a list of partition names. If the specified path cannot be mapped into a valid partition, it returns the default partition name, if indicated, or the absolute path itself. For example, given the list of partitions:- /
- /tmp
- /home
- /proc
- Parameters:
absolutePath
- The path whose partition match is being queried.partitioNames
- The list of partition names to query for the path match.defaultPartition
- The partition name used when no partition match is found.- Returns:
- Returns the string indicating the partition determined as the match for the given path.
- Throws:
ServiceException
-
getPartitionFreeSpace
long getPartitionFreeSpace(java.lang.String partitionName) throws ServiceException
This method is useful to developers when creating a custom bean. Returns the space available on the specified partition.- Parameters:
partitionName
- The name of the partition to query.- Returns:
- The free space on the named partition, in bytes.
- Throws:
ServiceException
- if an error occurred during the operation.
-
getPartitionFreeSpace
long getPartitionFreeSpace(java.lang.String partitionName, long requiredBytes) throws ServiceException
This method is useful to developers when creating a custom bean. Returns the space available on the specified partition. This variety of getpartitionFreeSpace can result in the expansion of the partition's file system in the event that the initial return value is less than requiredBytes. This method is useful for disk space checks that want to perform automatic file system expansion to minimized the occurrences of insufficient disk space.Platforms that do not support automatic file system expansion silently ignore requiredBytes.
- Parameters:
partitionName
- The name of the partition to query.requiredBytes
- The number of bytes required by an operation that is performing a space check.- Returns:
- The free space on the named partition, in bytes.
- Throws:
ServiceException
- if an error occurred during the operation.
-
getFileAttributes
FileAttributes getFileAttributes(java.lang.String file) throws ServiceException
This method is useful to developers when creating a custom bean. Returns a File attributes object containing the attributes of the specified file.- Parameters:
file
- The file to get the attributes from.- Returns:
- A FileAttributes object describing the attributes of the file. This object can be passed to setFileAttributes.
- Throws:
ServiceException
- if an error occurred during the operation.
-
setFileAttributes
void setFileAttributes(java.lang.String file, FileAttributes attributes) throws ServiceException
Sets the attributes of the specified file.- Parameters:
file
- The file the attributes should be applied to.attributes
- A FileAttributes object containing the desired file attributes.- Throws:
ServiceException
-
setFileExecutable
void setFileExecutable(java.lang.String file) throws ServiceException
Sets the attributes of the specified file to be an executable.- Parameters:
file
- The file the attributes should be applied to.- Throws:
ServiceException
-
getFileOwner
java.lang.String getFileOwner(java.lang.String file) throws ServiceException
Gets a file's owner.- Parameters:
file
- The name of the file from which to get the owner.- Returns:
- A String representing the userid that owns the file.
- Throws:
ServiceException
-
setFileOwner
void setFileOwner(java.lang.String file, java.lang.String userid) throws ServiceException
Sets a file's owner.- Parameters:
file
- The file for which to set the owner.userid
- The userid that will own the file.- Throws:
ServiceException
-
getFileOwnerGroup
java.lang.String getFileOwnerGroup(java.lang.String file) throws ServiceException
Gets a file's owner group.- Parameters:
file
- The file from which to get the owner group.- Returns:
- A String representing the groupid that owns the file.
- Throws:
ServiceException
-
setFileOwnerGroup
void setFileOwnerGroup(java.lang.String file, java.lang.String groupid) throws ServiceException
Sets a file's owner group.- Parameters:
file
- The file for which to set the owner group.groupid
- The groupid that will own the file.- Throws:
ServiceException
-
supportsLongFileNames
boolean supportsLongFileNames(java.lang.String partition) throws ServiceException
This method is useful to developers when creating a custom bean. Queries whether long file names are supported on a particular partition.- Parameters:
partition
- The partition to check for long file name support.- Returns:
- "true" if the partition supports long file names.
- Throws:
ServiceException
-
isDirectoryWritable
boolean isDirectoryWritable(java.lang.String directory) throws ServiceException
This method is useful to developers when creating a custom bean. Queries whether a directory is writable.- Parameters:
directory
- The directory to check.- Returns:
- "True" if the directory can be written to.
- Throws:
ServiceException
-
getPartitionType
int getPartitionType(java.lang.String directory) throws ServiceException
This method is useful to developers when creating a custom bean. Queries the partition type for the specified directory.- Parameters:
directory
- The directory for which to return the partition type.- Returns:
- int Returns the type of the partition (FIXED, REMOVABLE).
- Throws:
ServiceException
-
getPartitionFormat
java.lang.String getPartitionFormat(java.lang.String partition) throws ServiceException
This method is useful to developers when creating a custom bean. Queries the format of a particular partition.- Parameters:
partition
- The partition for which to return the format.- Returns:
- int Returns the format of the partition (FAT, NTFS, HPFS, JFS).
- Throws:
ServiceException
-
createAsciiFile
void createAsciiFile(java.lang.String fileName, java.lang.String[] content) throws ServiceException
This method is useful to developers when creating a custom bean. Creates an ASCII file containing the lines specified.- Parameters:
fileName
- Name of the file to create.content
- The ASCII lines for the file to contain.- Throws:
ServiceException
-
createAsciiFile
void createAsciiFile(java.lang.String fileName, java.lang.String[] content, java.lang.String fileEncoding) throws ServiceException
This method is useful to developers when creating a custom bean. Creates an ASCII file containing the lines specified.- Parameters:
fileName
- Name of the file to create.content
- The ASCII lines for the file to contain.fileEncoding
- File encoding to be used.- Throws:
ServiceException
-
createBinaryFile
void createBinaryFile(java.lang.String fileName, byte[] content) throws ServiceException
This method is useful to developers when creating a custom bean. Creates a binary file containing the bytes specified.- Parameters:
fileName
- Name of the file to create.content
- The bytes that the file should contain.- Throws:
ServiceException
-
appendToAsciiFile
void appendToAsciiFile(java.lang.String fileName, java.lang.String[] content) throws ServiceException
Appends lines to an ASCII file.- Parameters:
fileName
- Name of the file to append.content
- The ASCII lines to append to the file.- Throws:
ServiceException
-
appendBinaryFile
void appendBinaryFile(java.lang.String fileName, byte[] content) throws ServiceException
Appends bytes to a binary file.- Parameters:
fileName
- Name of the file to append.content
- The bytes to append to the file.- Throws:
ServiceException
-
readAsciiFile
java.lang.String[] readAsciiFile(java.lang.String fileName) throws ServiceException
Returns all of the lines of an ASCII file.- Parameters:
fileName
- Name of the file to read.- Returns:
- Returns all of the lines contained in the ASCII file.
- Throws:
ServiceException
-
readAsciiFile
java.lang.String[] readAsciiFile(java.lang.String fileName, java.lang.String fileEncoding) throws ServiceException
Returns all of the lines of an ASCII file.- Parameters:
fileName
- Name of the file to read.fileEncoding
- File encoding to be used.- Returns:
- Returns all of the lines contained in the ASCII file.
- Throws:
ServiceException
-
readAsciiFile
int readAsciiFile(java.lang.String fileName, java.lang.String[] linesRead, int start, int number) throws ServiceException
Reads lines in an ASCII file, starting at a specified line, and reading a specified number of lines. Returns the number of lines read.- Parameters:
fileName
- Name of the file to read.linesRead
- Array of the lines read from the file of size number.start
- The line to start reading from in the file.number
- The number of lines to read from the file.- Returns:
- The number of lines read from the file.
- Throws:
ServiceException
-
readBinaryFile
int readBinaryFile(java.lang.String fileName, byte[] bytesRead, int start, int number) throws ServiceException
Reads bytes in a binary file, starting at a specified offset, and reading a specified number of bytes. Returns the number of bytes read.- Parameters:
fileName
- Name of the file to read.bytesRead
- Arrary of the bytes read from the file of size number.start
- The offset to start reading from in the file.number
- The number of bytes to read from the file.- Returns:
- The number of bytes read from the file.
- Throws:
ServiceException
-
updateAsciiFile
void updateAsciiFile(java.lang.String fileName, java.lang.String[] lines, int start) throws ServiceException
Updates the lines in an ASCII file starting at and including the specified line.- Parameters:
fileName
- Name of the file to update.lines
- Array of the lines to update in the file.start
- First line in the file to update.- Throws:
ServiceException
-
updateBinaryFile
void updateBinaryFile(java.lang.String fileName, byte[] bytes, int start) throws ServiceException
Updates the bytes in a binary file starting at and including the specified offset.- Parameters:
fileName
- Name of the file to update.bytes
- Array of the bytes to update in the file.start
- First byte in the file to update.- Throws:
ServiceException
-
getFileSize
int getFileSize(java.lang.String fileName) throws ServiceException
Returns the size of an a file (in bytes).- Parameters:
fileName
- Name of the file from which to get the size.- Returns:
- The number of bytes in the file.
- Throws:
ServiceException
-
calculateDirectorySize
long calculateDirectorySize(java.lang.String dirName) throws ServiceException
Calculates the size of a given directory recursively and returns the total size (in bytes).- Parameters:
dirName
- Name of the directory to get size from.- Returns:
- The number of bytes associated with the indicated directory.
- Throws:
ServiceException
-
getAsciiFileLineCount
int getAsciiFileLineCount(java.lang.String fileName) throws ServiceException
Returns the number of lines in an ASCII file.- Parameters:
fileName
- Name of the file from which to get lines.- Returns:
- The number of lines in file.
- Throws:
ServiceException
-
copyDirectory
void copyDirectory(java.lang.String source, java.lang.String target, boolean copySubDirectories, boolean overwrite) throws ServiceException
This method is useful to developers when creating a custom bean. Copies the contents of the source directory to the target location.- Parameters:
source
- The directory to copytarget
- The destination of the source directory contents.copySubDirectories
- If "true", subdirectories are copied.overwrite
- If "true", existing files of the same name are replaced; if "false", existing files are preserved, and a ServiceException is thrown.- Throws:
ServiceException
- if the operation failed -- Upon failure, no attempt is made to restore the file system to its original state before the copy.
-
comparePaths
boolean comparePaths(java.lang.String path1, java.lang.String path2) throws ServiceException
Verifies whether or not two paths are the same, taking into account multiple path separators and folder relocators within the path (such as "/." and "/..").- Throws:
ServiceException
-
setSystemUMask
void setSystemUMask(int mode) throws ServiceException
Modifies the system umask for the current process. On systems that do not support a umask, ServiceException.OPERATION_NOT_SUPPORTED will be the error code of the ServiceException that is thrown.- Parameters:
mode
- The umask value to set- Throws:
ServiceException
-
getSystemUMask
int getSystemUMask() throws ServiceException
Returns the umask setting for the current process. On systems that do not support a umask, ServiceException.OPERATION_NOT_SUPPORTED will be the error code of the ServiceException that is thrown.- Returns:
- The umask value for the current process
- Throws:
ServiceException
-
validateFileName
void validateFileName(java.lang.String fileName) throws ServiceException
Validates the specified file name. If the file name is invalid (e.g. contains invalid characters, etc.) a ServiceException will be thrown. Use ServiceException.getMessage to obtain a localized error message that can be displayed to the user.- Throws:
ServiceException
-
createFileName
java.lang.String createFileName(java.lang.String context, java.lang.String fileName) throws ServiceException
This method is useful to developers when creating a custom bean. Returns a file name using context and fileName. If fileName is absolute, it is returned without modification. If fileName is relative, it is appended to context to form a qualified file name. fileName can be null, in which case context is returned. If context is null, it is treated as if it is an empty string.- Parameters:
context
- The context used to construct the file name.fileName
- The absolute or relative file name used to construct the full file name.- Returns:
- The reulting file name constructed from the fileName and context.
- Throws:
ServiceException
- if an error occurred during the operation.
-
isAbsolute
boolean isAbsolute(java.lang.String fileName) throws ServiceException
This method is useful to developers when creating a custom bean. Returns a boolean indicating whether or not the given file name is an absolute path.- Parameters:
fileName
- The file name to be examined.- Returns:
- A boolean indicating whether or not the indicated file name is absolute.
- Throws:
ServiceException
- if an error occurred during the operation.
-
normalizeFileName
java.lang.String normalizeFileName(java.lang.String fileName, char normalSeparator) throws ServiceException
This method is useful to developers when creating a custom bean. Returns a copy of fileName with all instances of normal separator characters replaced with the separator indicated.- Parameters:
fileName
- The fileName to be normalized.normalSeparator
- The separator character used to normalize fileName.- Returns:
- The normalized file name string.
- Throws:
ServiceException
- if an error occurred during the operation.
-
normalizeFileName
java.lang.String normalizeFileName(java.lang.String fileName) throws ServiceException
This method is useful to developers when creating a custom bean. Returns a copy of fileName with all instances of normal separator characters replaced with the file separator of the target system.- Parameters:
fileName
- The fileName to be normalized.- Returns:
- The normalized file name string.
- Throws:
ServiceException
- if an error occurred during the operation.
-
getPlatformId
java.lang.String getPlatformId() throws ServiceException
NOTE : This API is for internal use. Customer use is not recommended.Overridden for each platform to use in determining "extra" information to be used from a Files bean to handle platform-specific file version checking.
- Throws:
ServiceException
-
createSymbolicLink
void createSymbolicLink(java.lang.String target, java.lang.String linkName, boolean forceLink) throws ServiceException
This method is used to create a symbolic link on unix based platforms. It performs no operation on other platforms- Parameters:
target
- The target at which the link is pointinglinkName
- The name of the link to be created- Throws:
ServiceException
-
removeSymbolicLink
void removeSymbolicLink(java.lang.String linkName) throws ServiceException
This method is used to remove a symbolic link on unix based platforms. It performs no operation on other platforms- Parameters:
linkName
- The name of the link to be removed- Throws:
ServiceException
-
-