Interface nsIZipWriterType

nsIZipWriter

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.

Hierarchy

Properties

comment: string

Gets or sets the comment associated with the open zip file.

Throws

NS_ERROR_NOT_INITIALIZED if no zip file has been opened

file: nsIFile

The file that the zipwriter is writing to.

inQueue: boolean

Indicates that operations on the background queue are being performed.

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • 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.

    Throws

    NS_ERROR_NOT_INITIALIZED if no zip file has been opened

    Throws

    NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the zip

    Throws

    NS_ERROR_IN_PROGRESS if another operation is currently in progress

    Throws

    NS_ERROR_INVALID_ARG if aModTime is older than 1980-1-1

    Parameters

    • aZipEntry: string

      the path of the file entry

    • aModTime: number

      the modification time of the entry in microseconds

    • aCompression: int32_t

      the compression level, 0 is no compression, 9 is best

    • aChannel: nsIChannel

      the channel to get the data from

    • aQueue: boolean

      adds the operation to the background queue. Will be performed when processQueue is called.

    Returns void

  • Adds a new directory entry to the zip file. If aZipEntry does not end with "/" then it will be added.

    Throws

    NS_ERROR_NOT_INITIALIZED if no zip file has been opened

    Throws

    NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the file

    Throws

    NS_ERROR_IN_PROGRESS if another operation is currently in progress

    Throws

    NS_ERROR_INVALID_ARG if aModTime is older than 1980-1-1

    Parameters

    • aZipEntry: string

      the path of the directory entry

    • aModTime: number

      the modification time of the entry in microseconds

    • aQueue: boolean

      adds the operation to the background queue. Will be performed when processQueue is called.

    Returns void

  • 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, aFile.lastModifiedTime, aQueue)

    Throws

    NS_ERROR_NOT_INITIALIZED if no zip file has been opened

    Throws

    NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the zip

    Throws

    NS_ERROR_IN_PROGRESS if another operation is currently in progress

    Throws

    NS_ERROR_FILE_NOT_FOUND if file does not exist

    Parameters

    • aZipEntry: string

      the path of the file entry

    • aCompression: int32_t

      the compression level, 0 is no compression, 9 is best

    • aFile: nsIFile

      the file to get the data and modification time from

    • aQueue: boolean

      adds the operation to the background queue. Will be performed when processQueue is called.

    Returns void

  • Adds data from an input stream to the zip file.

    Throws

    NS_ERROR_NOT_INITIALIZED if no zip file has been opened

    Throws

    NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the zip

    Throws

    NS_ERROR_IN_PROGRESS if another operation is currently in progress

    Throws

    NS_ERROR_INVALID_ARG if aModTime is older than 1980-1-1

    Parameters

    • aZipEntry: string

      the path of the file entry

    • aModTime: number

      the modification time of the entry in microseconds

    • aCompression: int32_t

      the compression level, 0 is no compression, 9 is best

    • aStream: nsIInputStream

      the input stream to get the data from

    • aQueue: boolean

      adds the operation to the background queue. Will be performed when processQueue is called.

    Returns void

  • Make all stored(uncompressed) files align to given alignment size.

    Throws

    NS_ERROR_INVALID_ARG if aAlignSize is invalid

    Throws

    on failure to update the zip file

    Parameters

    • aAlignSize: uint16_t

      is the alignment size, valid values from 2 to 32768, and must be power of 2.

    Returns void

  • Closes the zip file.

    Throws

    NS_ERROR_NOT_INITIALIZED if no zip file has been opened

    Throws

    NS_ERROR_IN_PROGRESS if another operation is currently in progress

    Throws

    on failure to complete the zip file

    Returns void

  • Returns a nsIZipEntry describing a specified zip entry or null if there is no such entry in the zip file

    Parameters

    • aZipEntry: string

      the path of the entry

    Returns nsIZipEntry

  • Checks whether the zipfile contains an entry specified by zipEntry.

    Parameters

    • aZipEntry: string

      the path of the entry

    Returns boolean

  • Opens a zip file.

    Throws

    NS_ERROR_ALREADY_INITIALIZED if a zip file is already open

    Throws

    NS_ERROR_INVALID_ARG if aFile is null

    Throws

    NS_ERROR_FILE_NOT_FOUND if aFile does not exist and flags did not allow for creation

    Throws

    NS_ERROR_FILE_CORRUPTED if the file does not contain zip markers

    Throws

    on failure to open zip file (most likely corrupt or unsupported form)

    Parameters

    • aFile: nsIFile

      the zip file to open

    • aIoFlags: int32_t

      the open flags for the zip file from prio.h

    Returns void

  • 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.

    Throws

    NS_ERROR_NOT_INITIALIZED if no zip file has been opened

    Throws

    NS_ERROR_IN_PROGRESS if the queue is already in progress

    Parameters

    • aObserver: nsIRequestObserver
    • aContext: nsISupports

    Returns void

  • Removes an existing entry from the zip file.

    Throws

    NS_ERROR_NOT_INITIALIZED if no zip file has been opened

    Throws

    NS_ERROR_IN_PROGRESS if another operation is currently in progress

    Throws

    NS_ERROR_FILE_NOT_FOUND if no entry with the given path exists

    Throws

    on failure to update the zip file

    Parameters

    • aZipEntry: string

      the path of the entry to be removed

    • aQueue: boolean

      adds the operation to the background queue. Will be performed when processQueue is called.

    Returns void

Generated using TypeDoc