nsIZipWriter
| IID: | 6d4ef074-206c-4649-9884-57bc355864d6 |
| Inherits From: | nsISupports |
An interface for a zip archiver that can be used from script.
The interface supports both a synchronous method of archiving data and a queueing system to allow operations to be prepared then run in sequence with notification after completion.
Operations added to the queue do not get performed until performQueue is called at which point they will be performed in the order that they were added to the queue.
Operations performed on the queue will throw any errors out to the observer.
An attempt to perform a synchronous operation while the background queue is in progress will throw NS_ERROR_IN_PROGRESS.
Entry names should use /'s as path separators and should not start with a /.
It is not generally necessary to add directory entries in order to add file entries within them, however it is possible that some zip programs may experience problems what that.
This interface is implemented by the following components:
Constants
| Some predefined compression levels | ||
| PRUint32 | COMPRESSION_NONE | = 0 |
| PRUint32 | COMPRESSION_FASTEST | = 1 |
| PRUint32 | COMPRESSION_DEFAULT | = 6 |
| PRUint32 | COMPRESSION_BEST | = 9 |
Properties
ACString comment
Gets or sets the comment associated with the open zip file.
readonly nsIFile file
The file that the zipwriter is writing to.
readonly PRBool inQueue
Indicates that operations on the background queue are being performed.
Methods
void addEntryChannel ( AUTF8String zipEntry , PRTime modTime , PRInt32 compression , nsIChannel channel , PRBool queue )
void addEntryDirectory ( AUTF8String zipEntry , PRTime modTime , PRBool queue )
void addEntryFile ( AUTF8String zipEntry , PRInt32 compression , nsIFile file , PRBool queue )
void addEntryStream ( AUTF8String zipEntry , PRTime modTime , PRInt32 compression , nsIInputStream stream , PRBool queue )
void close ( )
nsIZipEntry getEntry ( AUTF8String zipEntry )
PRBool hasEntry ( AUTF8String zipEntry )
void open ( nsIFile file , PRInt32 ioFlags )
void processQueue ( nsIRequestObserver observer , nsISupports context )
void removeEntry ( AUTF8String zipEntry , PRBool queue )
void addEntryChannel ( AUTF8String zipEntry , PRTime modTime , PRInt32 compression , nsIChannel channel , PRBool queue )
Adds data from a channel to the zip file. If the operation is performed on the queue then the channel will be opened asynchronously, otherwise the channel must support being opened synchronously.
- Arguments:
- zipEntry: the path of the file entry
- modTime: the modification time of the entry in microseconds
- compression: the compression level, 0 is no compression, 9 is best
- channel: the channel to get the data from
- queue: adds the operation to the background queue. Will be performed when processQueue is called.
void addEntryDirectory ( AUTF8String zipEntry , PRTime modTime , PRBool queue )
Adds a new directory entry to the zip file. If zipEntry does not end with "/" then it will be added.
- Arguments:
- zipEntry: the path of the directory entry
- modTime: the modification time of the entry in microseconds
- queue: adds the operation to the background queue. Will be performed when processQueue is called.
void addEntryFile ( AUTF8String zipEntry , PRInt32 compression , nsIFile file , PRBool queue )
Adds a new file or directory to the zip file. If the specified file is a directory then this will be equivalent to a call to addEntryDirectory(aZipEntry, file.lastModifiedTime, queue)
- Arguments:
- zipEntry: the path of the file entry
- compression: the compression level, 0 is no compression, 9 is best
- file: the file to get the data and modification time from
- queue: adds the operation to the background queue. Will be performed when processQueue is called.
void addEntryStream ( AUTF8String zipEntry , PRTime modTime , PRInt32 compression , nsIInputStream stream , PRBool queue )
Adds data from an input stream to the zip file.
- Arguments:
- zipEntry: the path of the file entry
- modTime: the modification time of the entry in microseconds
- compression: the compression level, 0 is no compression, 9 is best
- stream: the input stream to get the data from
- queue: adds the operation to the background queue. Will be performed when processQueue is called.
nsIZipEntry getEntry ( AUTF8String zipEntry )
Returns a nsIZipEntry describing a specified zip entry or null if there is no such entry in the zip file
- Arguments:
- zipEntry: the path of the entry
PRBool hasEntry ( AUTF8String zipEntry )
Checks whether the zipfile contains an entry specified by zipEntry.
- Arguments:
- zipEntry: the path of the entry
void open ( nsIFile file , PRInt32 ioFlags )
Opens a zip file.
- Arguments:
- file: the zip file to open
- ioFlags: the open flags for the zip file from prio.h
void processQueue ( nsIRequestObserver observer , nsISupports context )
Processes all queued items until complete or some error occurs. The observer will be notified when the first operation starts and when the last operation completes. Any failures will be passed to the observer. The zip writer will be busy until the queue is complete or some error halted processing of the queue early. In the event of an early failure, remaining items will stay in the queue and calling processQueue will continue.
- Arguments:
- observer
- context
void removeEntry ( AUTF8String zipEntry , PRBool queue )
Removes an existing entry from the zip file.
- Arguments:
- zipEntry: the path of the entry to be removed
- queue: adds the operation to the background queue. Will be performed when processQueue is called.
Reference documentation is generated from Mozilla's source.
