|
RSE Release 3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.rse.services.clientserver.archiveutils.SystemZipHandler
public class SystemZipHandler
Implements an ISystemArchiveHandler for ZIP files.
Field Summary | |
---|---|
protected boolean |
_exists
|
protected File |
_file
|
protected SystemReentrantMutex |
_mutex
|
protected long |
_vfsLastModified
|
protected HashMap |
_virtualFS
|
protected ZipFile |
_zipfile
|
Constructor Summary | |
---|---|
SystemZipHandler(File file)
Creates a new SystemZipHandler and associates it with file . |
Method Summary | |
---|---|
void |
add(File[] files,
String virtualPath,
String[] names,
ISystemOperationMonitor archiveOperationMonitor)
A generalization of the add method. |
void |
add(File[] files,
String virtualPath,
String[] names,
String[] sourceEncodings,
String[] targetEncodings,
boolean[] isText,
boolean closeZipFile,
ISystemOperationMonitor archiveOperationMonitor)
Same as add(File[] files, String virtualPath, String[] names, String[] encodings) but you can choose whether or not you want to leave the zipfile open after return. |
void |
add(File[] files,
String virtualPath,
String[] names,
String[] sourceEncodings,
String[] targetEncodings,
boolean[] isText,
ISystemOperationMonitor archiveOperationMonitor)
A generalization of the add method. |
void |
add(File file,
String virtualPath,
String name,
ISystemOperationMonitor archiveOperationMonitor)
Compresses the file file and adds it to the archive, placing
it in the virtual directory virtualPath . |
void |
add(File file,
String virtualPath,
String name,
String sourceEncoding,
String targetEncoding,
boolean isText,
ISystemOperationMonitor archiveOperationMonitor)
Compresses the file file and adds it to the archive, saving
it in the encoding specified by encoding if the isText is
true. placing it in the virtual directory virtualPath . |
void |
add(File file,
String virtualPath,
String name,
String sourceEncoding,
String targetEncoding,
ISystemFileTypes registry,
ISystemOperationMonitor archiveOperationMonitor)
Compresses the file file and adds it to the archive, saving
it in the encoding specified by encoding if the isText is
true. placing it in the virtual directory virtualPath . |
void |
add(InputStream stream,
String virtualPath,
String name,
String sourceEncoding,
String targetEncoding,
boolean isText,
ISystemOperationMonitor archiveOperationMonitor)
Compresses the bytes in the InputStream stream and adds them
as an entry to the archive, saving them in the encoding specified by
encoding if isText is true, and placing it in
the virtual directory virtualPath . |
protected ZipEntry |
appendBytes(InputStream stream,
ZipOutputStream dest,
String virtualPath,
String name,
String sourceEncoding,
String targetEncoding,
boolean isText)
Compresses the contents of stream , adding them to the
ZipFile managed by dest . |
protected ZipEntry |
appendEmptyFile(ZipOutputStream dest,
String name)
Works similarly to appendFile, except no actual data is appended to the zipfile, only an entry is created. |
protected ZipEntry |
appendFile(File file,
ZipOutputStream dest,
String virtualPath,
String name,
String sourceEncoding,
String targetEncoding,
boolean isText)
Compresses the contents of file , adding them to the ZipFile
managed by dest . |
protected void |
buildTree()
Builds the virtual file system tree out of the entries in the zipfile. |
protected boolean |
closeZipFile()
|
void |
create()
Turns the archive that this handler represents into a new, empty archive. |
protected void |
createFile(File file)
Create an empty file, also creating parent folders if necessary. |
void |
createFile(String name,
ISystemOperationMonitor archiveOperationMonitor)
Creates a new, empty file in the archive. |
void |
createFolder(String name,
ISystemOperationMonitor archiveOperationMonitor)
Creates a new, empty folder in the archive. |
protected ZipEntry |
createSafeZipEntry(String name)
A "safe" ZipEntry is one whose virtual path does not begin with a "/". |
protected boolean |
createVirtualObject(String name,
boolean closeZipFile,
ISystemOperationMonitor archiveOperationMonitor)
Creates a new, empty object in the virtual File system, and creates an empty file or folder in the physical zip file. |
boolean |
delete(String fullVirtualName,
boolean closeZipFile,
ISystemOperationMonitor archiveOperationMonitor)
Same as delete(String fullVirtualName) but you can choose whether or not you want to leave the zipfile open after return. |
boolean |
delete(String fullVirtualName,
ISystemOperationMonitor archiveOperationMonitor)
Deletes the entry fullVirtualName from the archive, and
returns whether or not the deletion was successful. |
protected void |
delTree(VirtualChild vc)
Deletes all the children of the directory VirtualChild vc
recursively down to the leaves. |
boolean |
exists()
Check if the archive handler implementation associated with this class exists. |
boolean |
exists(String fullVirtualName,
ISystemOperationMonitor archiveOperationMonitor)
Check whether a given virtual node exists in an archive. |
void |
extractVirtualDirectory(String dir,
File destinationParent,
File destination,
ISystemOperationMonitor archiveOperationMonitor)
Extracts the directory dir (and its children) from the
archive and places the results in the directory
destinationParent . |
void |
extractVirtualDirectory(String dir,
File destinationParent,
File destination,
String sourceEncoding,
boolean isText,
ISystemOperationMonitor archiveOperationMonitor)
Extracts the directory dir (and its children) from the
archive and places the results in the directory
destinationParent . |
void |
extractVirtualDirectory(String dir,
File destinationParent,
ISystemOperationMonitor archiveOperationMonitor)
Extracts the directory dir (and its children) from the
archive and places the results in the directory
destinationParent . |
void |
extractVirtualDirectory(String dir,
File destinationParent,
String sourceEncoding,
boolean isText,
ISystemOperationMonitor archiveOperationMonitor)
Extracts the directory dir (and its children) from the
archive and places the results in the directory
destinationParent . |
void |
extractVirtualFile(String fullVirtualName,
File destination,
boolean closeZipFile,
String sourceEncoding,
boolean isText,
ISystemOperationMonitor archiveOperationMonitor)
Same as extractVirtualFile(String fullVirtualName, File destination) but you can choose whether or not you want to leave the zipfile open after return. |
void |
extractVirtualFile(String fullVirtualName,
File destination,
ISystemOperationMonitor archiveOperationMonitor)
Extracts the virtual file named fullVirtualName from the
archive, placing the results in destination . |
void |
extractVirtualFile(String fullVirtualName,
File destination,
String sourceEncoding,
boolean isText,
ISystemOperationMonitor archiveOperationMonitor)
Extracts the virtual file named fullVirtualName from the
archive, placing the results in destination . |
protected void |
fillBranch(ZipEntry next)
Populates an entire branch of the tree that comprises the virtual file system. |
protected void |
fillBranchAfterRename(ZipEntry next,
String oldName)
Populates an entire branch of the tree that comprises the virtual file system. |
void |
fullRename(String fullVirtualName,
String newFullVirtualName,
boolean closeZipFile,
ISystemOperationMonitor archiveOperationMonitor)
Same as fullRename(String fullVirtualName, String newFullVirtualName) but you can choose whether or not you want to leave the zipfile open after return. |
void |
fullRename(String fullVirtualName,
String newFullVirtualName,
ISystemOperationMonitor archiveOperationMonitor)
Replaces the full name and path of the entry fullVirtualName
with the new full name and path newFullVirtualName . |
File |
getArchive()
Return the archive that this handler deals with. |
String |
getArchiveComment()
Get the comment associated with an archive. |
String |
getClassification(String fullVirtualName)
Get the classification for the entry with the given path. |
String |
getClassification(String fullVirtualName,
boolean closeZipFile)
Same as getClassification(String), but you can choose whether to leave the zip file open after the method is closed. |
String |
getCommentFor(String fullVirtualName)
Get the user-defined comment for a specific entry in the archive. |
String |
getCommentFor(String fullVirtualName,
boolean closeZipFile)
same as getCommentFor(String) but you can choose whether or not to leave the zipfile open after the method is closed |
long |
getCompressedSizeFor(String fullVirtualName)
Get the amount of space taken up by a specific entry in the archive when it is in compressed form. |
long |
getCompressedSizeFor(String fullVirtualName,
boolean closeZipFile)
same as getCompressedSizeFor(String) but you can choose whether or not to leave the zipfile open after the method is closed |
String |
getCompressionMethodFor(String fullVirtualName)
Get the method used to compress a specific entry in the archive. |
String |
getCompressionMethodFor(String fullVirtualName,
boolean closeZipFile)
same as getCompressionMethodFor(String) but you can choose whether or not to leave the zipfile open after the method is closed |
File[] |
getFiles(String[] fullNames,
ISystemOperationMonitor archiveOperationMonitor)
Extracts and returns the specified list of virtual files from the archive. |
long |
getSizeFor(String fullVirtualName)
Return the size for an archive node. |
long |
getSizeFor(String fullVirtualName,
boolean closeZipFile)
Same as getSizeFor(String) but allows to specify whether to
close the zip file or not. |
String |
getStandardName(VirtualChild vc)
Get the archive-type specific standard name for the VirtualChild vc . |
long |
getTimeStampFor(String fullVirtualName)
Return the timestamp for an archive node. |
long |
getTimeStampFor(String fullVirtualName,
boolean closeZipFile)
Same as getTimeStampFor(String fullVirtualName) but you can choose whether or not you want to leave the zipfile open after return. |
VirtualChild[] |
getVirtualChildFolders(String fullVirtualName,
ISystemOperationMonitor archiveOperationMonitor)
Return those children of a specified node in an archive, which are folders. |
VirtualChild[] |
getVirtualChildren(String fullVirtualName,
ISystemOperationMonitor archiveOperationMonitor)
Return the children of a specified node in an archive. |
VirtualChild[] |
getVirtualChildrenList(boolean closeZipFile,
ISystemOperationMonitor archiveOperationMonitor)
Same as getVirtualChildrenList(), but you can choose whether to leave the zip file open or closed upon return. |
VirtualChild[] |
getVirtualChildrenList(ISystemOperationMonitor archiveOperationMonitor)
Return a flat list of entries in an archive. |
VirtualChild[] |
getVirtualChildrenList(String parent,
boolean closeZipFile,
ISystemOperationMonitor archiveOperationMonitor)
Same as getVirtualChildrenList(String parent) but you can choose whether or not you want to leave the zipfile open after return. |
VirtualChild[] |
getVirtualChildrenList(String parent,
ISystemOperationMonitor archiveOperationMonitor)
Return a flat list of entries in an archive, whose full paths begin with the given parent prefix. |
VirtualChild |
getVirtualFile(String fullVirtualName,
ISystemOperationMonitor archiveOperationMonitor)
Return an archive node specified by a given virtual path. |
static boolean |
listAllFiles(File parent,
HashSet found,
ISystemOperationMonitor archiveOperationMonitor)
Helper method. populates found with a collapsed list of
all nodes in the subtree of the file system rooted at parent . |
void |
move(String fullVirtualName,
String destinationVirtualPath,
ISystemOperationMonitor archiveOperationMonitor)
Moves the entry fullVirtualName to the location specified by
destinationVirtualPath , while leaving the entry with the
same name as before. |
protected boolean |
openZipFile()
Opens the zipfile that this handler manages. |
protected void |
populate(String key,
VirtualChild value)
|
protected boolean |
recreateZipDeleteEntries(VirtualChild[] vcList,
ZipOutputStream dest,
HashSet omitChildren,
ISystemOperationMonitor archiveOperationMonitor)
Recreates a zip file from a list of virtual children, optionally omitting a group of children whose names are in the Set omitChildren |
protected boolean |
recreateZipRenameEntries(VirtualChild[] vcList,
ZipOutputStream dest,
HashMap names,
ISystemOperationMonitor archiveOperationMonitor)
Recreates a zip file from a list of virtual children, but renaming the one of the VirtualChildren. |
protected void |
recursivePopulate(String key,
VirtualChild value)
Actually does the work for the fillBranch method. |
void |
rename(String fullVirtualName,
String newName,
ISystemOperationMonitor archiveOperationMonitor)
Renames the entry fullVirtualName to the new name
newName while still leaving the entry in the same virtual
directory. |
void |
replace(String fullVirtualName,
File file,
String name,
boolean closeZipFile,
ISystemOperationMonitor archiveOperationMonitor)
Same as replace(String fullVirtualName, File file, String name) but you can choose whether or not you want to leave the zipfile open after return. |
void |
replace(String fullVirtualName,
File file,
String name,
ISystemOperationMonitor archiveOperationMonitor)
Compress the file file and replace the virtual file referred
to by fullVirtualName with the compressed file. |
void |
replace(String fullVirtualName,
InputStream stream,
String name,
String sourceEncoding,
String targetEncoding,
boolean isText,
ISystemOperationMonitor archiveOperationMonitor)
Compress the InputStream stream and replace the virtual file
referred to by fullVirtualName with the compressed stream. |
protected void |
replaceOldZip(File outputTempFile)
Replaces the old zip file managed by this SystemZipHandler, with the zip file referred to by outputTempFile. |
protected ZipEntry |
safeGetEntry(String name)
Returns the entry corresponding to name from _zipfile. |
SystemSearchLineMatch[] |
search(String fullVirtualName,
SystemSearchStringMatcher matcher,
ISystemOperationMonitor archiveOperationMonitor)
Search for text within a virtual file in this archive. |
protected void |
updateTreeAfterRename(HashMap newOldName,
VirtualChild[] renameList)
Update the virtual file system tree after rename operation. |
protected boolean |
updateVirtualFSIfNecessary(ISystemOperationMonitor archiveOperationMonitor)
If the mod-times of the underlying zip file and the file used to create the virtualFS are different, update the virtualFS. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ZipFile _zipfile
protected HashMap _virtualFS
protected File _file
protected long _vfsLastModified
protected boolean _exists
protected SystemReentrantMutex _mutex
Constructor Detail |
---|
public SystemZipHandler(File file) throws IOException
file
.
file
- The file that this handler will wrapper.
IOException
- If there is an error handling file
Method Detail |
---|
protected void buildTree()
protected void updateTreeAfterRename(HashMap newOldName, VirtualChild[] renameList)
protected void fillBranch(ZipEntry next)
next
- The ZipEntry from which the branch will be built.protected void fillBranchAfterRename(ZipEntry next, String oldName)
next
- The ZipEntry from which the branch will be built.protected void recursivePopulate(String key, VirtualChild value)
protected void populate(String key, VirtualChild value)
public VirtualChild[] getVirtualChildrenList(ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
getVirtualChildrenList
in interface ISystemArchiveHandler
archiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic VirtualChild[] getVirtualChildrenList(boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
SystemMessageException
- in case of an errorpublic VirtualChild[] getVirtualChildrenList(String parent, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
getVirtualChildrenList
in interface ISystemArchiveHandler
parent
- full path of the parentarchiveOperationMonitor
- the operation progress monitor
parent
.
Returns an array of length 0 if there are no such entries.
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic VirtualChild[] getVirtualChildrenList(String parent, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
SystemMessageException
- in case of an errorpublic VirtualChild[] getVirtualChildren(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
getVirtualChildren
in interface ISystemArchiveHandler
fullVirtualName
- full virtual path of the parentarchiveOperationMonitor
- the operation progress monitor
fullVirtualName
. If fullVirtualName
is
"", returns the top level in the virtual file system tree. If there are
no values to return, returns null.public VirtualChild[] getVirtualChildFolders(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
getVirtualChildFolders
in interface ISystemArchiveHandler
fullVirtualName
- full virtual path of the parentarchiveOperationMonitor
- the operation progress monitor
fullVirtualName
that are themselves directories. If
fullVirtualName
is "", returns the top level of directories
in the virtual file system tree. If there are no values to return,
returns null.public VirtualChild getVirtualFile(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
getVirtualFile
in interface ISystemArchiveHandler
fullVirtualName
- full virtual path of the object to retrievearchiveOperationMonitor
- the operation progress monitor
fullVirtualName
. This method never returns null. In cases
where the VirtualChild does not physically exist in the archive, this
method returns a new VirtualChild object whose exists() method returns
false.public boolean exists(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
exists
in interface ISystemArchiveHandler
fullVirtualName
- full virtual path of the objectarchiveOperationMonitor
- the operation progress monitor
fullVirtualName
exists in the archive (physically).
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic File getArchive()
ISystemArchiveHandler
getArchive
in interface ISystemArchiveHandler
public long getTimeStampFor(String fullVirtualName) throws SystemMessageException
ISystemArchiveHandler
getTimeStampFor
in interface ISystemArchiveHandler
fullVirtualName
- virtual path specifying the node to check
fullVirtualName
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic long getTimeStampFor(String fullVirtualName, boolean closeZipFile) throws SystemMessageException
SystemMessageException
public long getSizeFor(String fullVirtualName) throws SystemMessageException
ISystemArchiveHandler
getSizeFor
in interface ISystemArchiveHandler
fullVirtualName
- virtual path specifying the node to check
fullVirtualName
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic long getSizeFor(String fullVirtualName, boolean closeZipFile) throws SystemMessageException
getSizeFor(String)
but allows to specify whether to
close the zip file or not.
fullVirtualName
- absolute virtual path to the node to inspectcloseZipFile
- true
if the zip file should be closed
SystemMessageException
ISystemArchiveHandler.getSizeFor(java.lang.String)
public void extractVirtualFile(String fullVirtualName, File destination, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
fullVirtualName
from the
archive, placing the results in destination
.
extractVirtualFile
in interface ISystemArchiveHandler
fullVirtualName
- The full path and name of the virtual file in the
archive.destination
- The destination file for the extracted virtual file.archiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void extractVirtualFile(String fullVirtualName, File destination, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
fullVirtualName
from the
archive, placing the results in destination
. Extracts to the
native encoding, but assumes that the source was archived using
sourceEncoding
if isText
is true.
extractVirtualFile
in interface ISystemArchiveHandler
fullVirtualName
- The full path and name of the virtual file in the
archive.destination
- The destination file for the extracted virtual file.sourceEncoding
- The encoding of the file in the archive.isText
- Whether or not the virtual file is a text file.archiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void extractVirtualFile(String fullVirtualName, File destination, boolean closeZipFile, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
SystemMessageException
public void extractVirtualDirectory(String dir, File destinationParent, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
dir
(and its children) from the
archive and places the results in the directory
destinationParent
.
extractVirtualDirectory
in interface ISystemArchiveHandler
dir
- The full name of the virtual directory to extractdestinationParent
- A handle to the directory in which the extracted
directory will be placed as a subdirectory.archiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void extractVirtualDirectory(String dir, File destinationParent, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
dir
(and its children) from the
archive and places the results in the directory
destinationParent
. Extracts to the native encoding (if
isText
), but assumes that the source was archived using
sourceEncoding
.
extractVirtualDirectory
in interface ISystemArchiveHandler
dir
- The full name of the virtual directory to extractdestinationParent
- A handle to the directory in which the extracted
directory will be placed as a subdirectory.sourceEncoding
- The encoding of the files in the archive.isText
- Whether or not the files in the directory are text filesarchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void extractVirtualDirectory(String dir, File destinationParent, File destination, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
dir
(and its children) from the
archive and places the results in the directory
destinationParent
. The results will be named
destination.getName() rather than dir
's name.
extractVirtualDirectory
in interface ISystemArchiveHandler
dir
- The full name of the virtual directory to extractdestinationParent
- A handle to the directory in which the extracted
directory will be placed as a subdirectory.destination
- A handle to the directory that will be created.
Whatever contents are in that directory will be replaced with what
is extracted from the archive.archiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void extractVirtualDirectory(String dir, File destinationParent, File destination, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
dir
(and its children) from the
archive and places the results in the directory
destinationParent
. The results will be named
destination.getName() rather than dir
's name. Extracts to
the native encoding (if isText
), but assumes that the source
was archived using sourceEncoding
.
extractVirtualDirectory
in interface ISystemArchiveHandler
dir
- The full name of the virtual directory to extractdestinationParent
- A handle to the directory in which the extracted
directory will be placed as a subdirectory.destination
- A handle to the directory that will be created.
Whatever contents are in that directory will be replaced with what
is extracted from the archive.sourceEncoding
- The encoding of the files in the archive.isText
- Whether or not the files to be extracted in the directory
are all text filesarchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationprotected void createFile(File file) throws SystemMessageException
file
- An abstract file handle to create physically.
SystemMessageException
- in case of an error otherwise.public void add(File file, String virtualPath, String name, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
file
and adds it to the archive, placing
it in the virtual directory virtualPath
. Pass the name as
the parameter name
. If the virtual path does not exist in
the archive, create it. If file
is a directory, copy it and
its contents into the archive, maintaining the tree structure.
add
in interface ISystemArchiveHandler
file
- the file to be added to the archivevirtualPath
- the destination of the filename
- the name of the result virtual filearchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void add(InputStream stream, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
stream
and adds them
as an entry to the archive, saving them in the encoding specified by
encoding
if isText
is true, and placing it in
the virtual directory virtualPath
. Pass the name as the
parameter name
. If the virtual path does not exist in the
archive, create it.
add
in interface ISystemArchiveHandler
stream
- the InputStream to be added as an entry to the archivevirtualPath
- the destination of the streamname
- the name of the result virtual filesourceEncoding
- the encoding of the source streamtargetEncoding
- the encoding of the result fileisText
- is the file a text filearchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void add(File[] files, String virtualPath, String[] names, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
files
and adds each of them to the archive, placing them in
the virtual directory virtualPath
. Pass the names of the
files as the parameter names
, where files[i]
has the name names[i]
. If the virtual path does not exist in
the archive, create it.
add
in interface ISystemArchiveHandler
files
- the list of files to be added to the archivevirtualPath
- the destination of the filenames
- the names of the result virtual filesarchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void add(File[] files, String virtualPath, String[] names, String[] sourceEncodings, String[] targetEncodings, boolean[] isText, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
files
and adds each of them to the archive, placing them in
the virtual directory virtualPath
. Save the i'th file in the
i'th encoding (if isText[i] is true) specified by encodings
.
Pass the names of the files as the parameter names
, where
files[i]
has the name names[i]
. If the virtual
path does not exist in the archive, create it.
add
in interface ISystemArchiveHandler
files
- the list of files to be added to the archivevirtualPath
- the destination of the filesnames
- the names of the result virtual filessourceEncodings
- the encoding of the source filestargetEncodings
- the encoding of the result filesisText
- file transfer mode (binary or text) of the filesarchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void add(File[] files, String virtualPath, String[] names, String[] sourceEncodings, String[] targetEncodings, boolean[] isText, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
SystemMessageException
public static boolean listAllFiles(File parent, HashSet found, ISystemOperationMonitor archiveOperationMonitor)
found
with a collapsed list of
all nodes in the subtree of the file system rooted at parent
.
protected boolean recreateZipDeleteEntries(VirtualChild[] vcList, ZipOutputStream dest, HashSet omitChildren, ISystemOperationMonitor archiveOperationMonitor) throws IOException
vcList
- The list of virtual children to create the zip fromdest
- The ZipOutputStream representing the zip file where the
children are to be recreatedomitChildren
- The set of names of children to omit when creating
the zipfile. Null or empty set if there are no omissions.
true
if the operation is cancelled
IOException
- in case of a file I/O errorprotected boolean recreateZipRenameEntries(VirtualChild[] vcList, ZipOutputStream dest, HashMap names, ISystemOperationMonitor archiveOperationMonitor) throws IOException
vcList
- The list of virtual children to create the zip fromdest
- The ZipOutputStream representing the zip file where the
children are to be recreatednames
- HashMap maps the full path of a virtual file to the entry in
the archive file
true
if the operation has been cancelled
IOException
- in case of an error.protected ZipEntry appendFile(File file, ZipOutputStream dest, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText) throws IOException
file
, adding them to the ZipFile
managed by dest
. The file is encoded in the encoding
specified by encoding
. A new entry is created in the ZipFile
with virtual path and name of virtualPath
and
name
respectively.
IOException
- in case of an error.protected ZipEntry appendBytes(InputStream stream, ZipOutputStream dest, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText) throws IOException
stream
, adding them to the
ZipFile managed by dest
. The stream is encoded in the
encoding specified by encoding
. A new entry is created in
the ZipFile with virtual path and name of virtualPath
and
name
respectively.
IOException
- in case of an error.protected void replaceOldZip(File outputTempFile) throws IOException
IOException
- if outputTempFile cannot be used as a ZipFile.public boolean delete(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
fullVirtualName
from the archive, and
returns whether or not the deletion was successful.
delete
in interface ISystemArchiveHandler
fullVirtualName
- the path of the file to be deletedarchiveOperationMonitor
- the operation progress monitor
true
if the deletion is successful,
false
if the file to delete was not found so this was a
successful no-op.
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic boolean delete(String fullVirtualName, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
SystemMessageException
protected void delTree(VirtualChild vc)
vc
recursively down to the leaves.
Pre: vc.isDirectory is true
vc
- The child whose children we are deleting.public void replace(String fullVirtualName, File file, String name, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
file
and replace the virtual file referred
to by fullVirtualName
with the compressed file. Pass the
name of the file as the parameter name
.
replace
in interface ISystemArchiveHandler
fullVirtualName
- the path of the file to be replacedfile
- the file to be added to the archivename
- the name of the filearchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void replace(String fullVirtualName, File file, String name, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
SystemMessageException
public void replace(String fullVirtualName, InputStream stream, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
stream
and replace the virtual file
referred to by fullVirtualName
with the compressed stream.
Pass the name of the new entry as the parameter name
, the
encoding of the entry as encoding
and whether or not the
entry isText
or not.
replace
in interface ISystemArchiveHandler
fullVirtualName
- the path of the file to be replacedstream
- the InputStream to be added as an entry to the archivename
- the name of the result virtual filesourceEncoding
- the encoding of the source streamtargetEncoding
- the encoding of the result fileisText
- is the file a text filearchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void fullRename(String fullVirtualName, String newFullVirtualName, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
fullVirtualName
with the new full name and path newFullVirtualName
.
fullRename
in interface ISystemArchiveHandler
fullVirtualName
- the path of the file to be renamednewFullVirtualName
- the full path of the virtual file namearchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void fullRename(String fullVirtualName, String newFullVirtualName, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
SystemMessageException
- in case of an error or user cancellation.public void move(String fullVirtualName, String destinationVirtualPath, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
fullVirtualName
to the location specified by
destinationVirtualPath
, while leaving the entry with the
same name as before.
move
in interface ISystemArchiveHandler
fullVirtualName
- the path of the file to be renameddestinationVirtualPath
- the destination of the file to move toarchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void rename(String fullVirtualName, String newName, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
fullVirtualName
to the new name
newName
while still leaving the entry in the same virtual
directory. Returns true if and only if the rename was successful.
rename
in interface ISystemArchiveHandler
fullVirtualName
- the path of the file to be renamedarchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic File[] getFiles(String[] fullNames, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
getFiles
in interface ISystemArchiveHandler
fullNames
- The list of files to returnarchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void createFolder(String name, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
createFolder
in interface ISystemArchiveHandler
name
- The full name and path of the new folder within
the virtual file system.archiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void createFile(String name, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
createFile
in interface ISystemArchiveHandler
name
- The full name and path of the new file within the
virtual file system.archiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationprotected boolean createVirtualObject(String name, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
name
- The name of the file or folder to create. The object created
will be a folder if and only if name
ends in a "/".
true
if the object was created. false
if the creation was a no-op because the object already existed.
SystemMessageException
- in case of an error or cancellation.protected ZipEntry appendEmptyFile(ZipOutputStream dest, String name) throws IOException
dest
- The destination zip stream to append the entry.name
- The new, virtual fullname to give the entry.
IOException
- If there was an error appending the entry to the stream.protected ZipEntry createSafeZipEntry(String name)
name
- The virtual name for the new, safe ZipEntry.
public String getStandardName(VirtualChild vc)
ISystemArchiveHandler
vc
. For example, for Zip archives, if vc is a directory,
then the standard name must end with a "/".
getStandardName
in interface ISystemArchiveHandler
vc
- the archive node to use
protected boolean openZipFile() throws IOException
IOException
- in case of an errorprotected boolean closeZipFile()
protected boolean updateVirtualFSIfNecessary(ISystemOperationMonitor archiveOperationMonitor)
protected ZipEntry safeGetEntry(String name) throws IOException
name
from _zipfile. Never returns
null, but rather, throws an IOException if it cannot find the entry. Tries to retrieve
both name
and "/" + name, to accomodate for zipfiles created
in a unix environment. ASSUMES THAT _zipfile IS ALREADY OPEN!
- Throws:
IOException
public void create() throws SystemMessageException
create
in interface ISystemArchiveHandler
SystemMessageException
- in case of an errorpublic SystemSearchLineMatch[] search(String fullVirtualName, SystemSearchStringMatcher matcher, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
search
in interface ISystemArchiveHandler
fullVirtualName
- the virtual file to search.matcher
- the pattern matcher to use.archiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic boolean exists()
ISystemArchiveHandler
exists
in interface ISystemArchiveHandler
public String getCommentFor(String fullVirtualName) throws SystemMessageException
ISystemArchiveHandler
getCommentFor
in interface ISystemArchiveHandler
fullVirtualName
- The entry who's comment is desired
SystemMessageException
- in case of an errorpublic String getCommentFor(String fullVirtualName, boolean closeZipFile) throws SystemMessageException
SystemMessageException
public long getCompressedSizeFor(String fullVirtualName) throws SystemMessageException
ISystemArchiveHandler
getCompressedSizeFor
in interface ISystemArchiveHandler
fullVirtualName
- The entry who's compressed size is desired
SystemMessageException
- in case of an errorpublic long getCompressedSizeFor(String fullVirtualName, boolean closeZipFile) throws SystemMessageException
SystemMessageException
public String getCompressionMethodFor(String fullVirtualName) throws SystemMessageException
ISystemArchiveHandler
getCompressionMethodFor
in interface ISystemArchiveHandler
fullVirtualName
- The entry who's compression method is desired
SystemMessageException
- in case of an errorpublic String getCompressionMethodFor(String fullVirtualName, boolean closeZipFile) throws SystemMessageException
SystemMessageException
public String getArchiveComment()
ISystemArchiveHandler
getArchiveComment
in interface ISystemArchiveHandler
public String getClassification(String fullVirtualName) throws SystemMessageException
ISystemArchiveHandler
getClassification
in interface ISystemArchiveHandler
fullVirtualName
- the virtual name.
SystemMessageException
- in case of an errorpublic String getClassification(String fullVirtualName, boolean closeZipFile) throws SystemMessageException
SystemMessageException
ISystemArchiveHandler.getClassification(java.lang.String)
public void add(File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, ISystemFileTypes registry, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
file
and adds it to the archive, saving
it in the encoding specified by encoding
if the isText is
true. placing it in the virtual directory virtualPath
. Pass
the name as the parameter name
. If the virtual path does not
exist in the archive, create it. If file
is a directory,
copy it and its contents into the archive, maintaining the tree
structure.
add
in interface ISystemArchiveHandler
file
- the file to be added to the archivevirtualPath
- the destination of the filename
- the name of the result virtual filesourceEncoding
- the encoding of the source filetargetEncoding
- the encoding of the result fileregistry
- file transfer mode (binary or text) of this filearchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellationpublic void add(File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) throws SystemMessageException
file
and adds it to the archive, saving
it in the encoding specified by encoding
if the isText is
true. placing it in the virtual directory virtualPath
. Pass
the name as the parameter name
. If the virtual path does not
exist in the archive, create it. If file
is a directory,
copy it and its contents into the archive, maintaining the tree
structure.
add
in interface ISystemArchiveHandler
file
- the file to be added to the archivevirtualPath
- the destination of the filename
- the name of the result virtual filesourceEncoding
- the encoding of the source filetargetEncoding
- the encoding of the result fileisText
- is the file a text filearchiveOperationMonitor
- the operation progress monitor
SystemMessageException
- in case of an error,
or SystemOperationCancelledException in case of user cancellation
|
RSE Release 3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |