modules/libjar/zipwriter/public/nsIZipWriter.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libjar/zipwriter/public/nsIZipWriter.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,220 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 + */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +interface nsIChannel;
    1.11 +interface nsIInputStream;
    1.12 +interface nsIRequestObserver;
    1.13 +interface nsIFile;
    1.14 +interface nsIZipEntry;
    1.15 +
    1.16 +/**
    1.17 + * nsIZipWriter
    1.18 + *
    1.19 + * An interface for a zip archiver that can be used from script.
    1.20 + *
    1.21 + * The interface supports both a synchronous method of archiving data and a
    1.22 + * queueing system to allow operations to be prepared then run in sequence
    1.23 + * with notification after completion.
    1.24 + *
    1.25 + * Operations added to the queue do not get performed until performQueue is
    1.26 + * called at which point they will be performed in the order that they were
    1.27 + * added to the queue.
    1.28 + *
    1.29 + * Operations performed on the queue will throw any errors out to the
    1.30 + * observer.
    1.31 + *
    1.32 + * An attempt to perform a synchronous operation while the background queue
    1.33 + * is in progress will throw NS_ERROR_IN_PROGRESS.
    1.34 + *
    1.35 + * Entry names should use /'s as path separators and should not start with
    1.36 + * a /.
    1.37 + *
    1.38 + * It is not generally necessary to add directory entries in order to add file
    1.39 + * entries within them, however it is possible that some zip programs may
    1.40 + * experience problems what that.
    1.41 + */
    1.42 +[scriptable, uuid(3ca10750-797e-4a22-bcfe-66170b5e96dd)]
    1.43 +interface nsIZipWriter : nsISupports
    1.44 +{
    1.45 +  /**
    1.46 +   * Some predefined compression levels
    1.47 +   */
    1.48 +  const uint32_t COMPRESSION_NONE    = 0;
    1.49 +  const uint32_t COMPRESSION_FASTEST = 1;
    1.50 +  const uint32_t COMPRESSION_DEFAULT = 6;
    1.51 +  const uint32_t COMPRESSION_BEST    = 9;
    1.52 +
    1.53 +  /**
    1.54 +   * Gets or sets the comment associated with the open zip file.
    1.55 +   *
    1.56 +   * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened
    1.57 +   */
    1.58 +  attribute ACString comment;
    1.59 +
    1.60 +  /**
    1.61 +   * Indicates that operations on the background queue are being performed.
    1.62 +   */
    1.63 +  readonly attribute boolean inQueue;
    1.64 +
    1.65 +  /**
    1.66 +   * The file that the zipwriter is writing to.
    1.67 +   */
    1.68 +  readonly attribute nsIFile file;
    1.69 +
    1.70 +  /**
    1.71 +   * Opens a zip file.
    1.72 +   *
    1.73 +   * @param aFile the zip file to open
    1.74 +   * @param aIoFlags the open flags for the zip file from prio.h
    1.75 +   *
    1.76 +   * @throws NS_ERROR_ALREADY_INITIALIZED if a zip file is already open
    1.77 +   * @throws NS_ERROR_INVALID_ARG if aFile is null
    1.78 +   * @throws NS_ERROR_FILE_NOT_FOUND if aFile does not exist and flags did
    1.79 +   *  not allow for creation
    1.80 +   * @throws NS_ERROR_FILE_CORRUPTED if the file does not contain zip markers
    1.81 +   * @throws <other-error> on failure to open zip file (most likely corrupt
    1.82 +   *  or unsupported form)
    1.83 +   */
    1.84 +  void open(in nsIFile aFile, in int32_t aIoFlags);
    1.85 +
    1.86 +  /**
    1.87 +   * Returns a nsIZipEntry describing a specified zip entry or null if there
    1.88 +   * is no such entry in the zip file
    1.89 +   *
    1.90 +   * @param aZipEntry the path of the entry
    1.91 +   */
    1.92 +  nsIZipEntry getEntry(in AUTF8String aZipEntry);
    1.93 +
    1.94 +  /**
    1.95 +   * Checks whether the zipfile contains an entry specified by zipEntry.
    1.96 +   *
    1.97 +   * @param aZipEntry the path of the entry
    1.98 +   */
    1.99 +  boolean hasEntry(in AUTF8String aZipEntry);
   1.100 +
   1.101 +  /**
   1.102 +   * Adds a new directory entry to the zip file. If aZipEntry does not end with
   1.103 +   * "/" then it will be added.
   1.104 +   *
   1.105 +   * @param aZipEntry the path of the directory entry
   1.106 +   * @param aModTime the modification time of the entry in microseconds
   1.107 +   * @param aQueue adds the operation to the background queue. Will be
   1.108 +   *        performed when processQueue is called.
   1.109 +   *
   1.110 +   * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened
   1.111 +   * @throws NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the
   1.112 +   *  file
   1.113 +   * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress
   1.114 +   */
   1.115 +  void addEntryDirectory(in AUTF8String aZipEntry, in PRTime aModTime,
   1.116 +                         in boolean aQueue);
   1.117 +
   1.118 +  /**
   1.119 +   * Adds a new file or directory to the zip file. If the specified file is
   1.120 +   * a directory then this will be equivalent to a call to
   1.121 +   * addEntryDirectory(aZipEntry, aFile.lastModifiedTime, aQueue)
   1.122 +   *
   1.123 +   * @param aZipEntry the path of the file entry
   1.124 +   * @param aCompression the compression level, 0 is no compression, 9 is best
   1.125 +   * @param aFile the file to get the data and modification time from
   1.126 +   * @param aQueue adds the operation to the background queue. Will be
   1.127 +   *        performed when processQueue is called.
   1.128 +   *
   1.129 +   * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened
   1.130 +   * @throws NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the zip
   1.131 +   * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress
   1.132 +   * @throws NS_ERROR_FILE_NOT_FOUND if file does not exist
   1.133 +   */
   1.134 +  void addEntryFile(in AUTF8String aZipEntry,
   1.135 +                    in int32_t aCompression, in nsIFile aFile,
   1.136 +                    in boolean aQueue);
   1.137 +
   1.138 +  /**
   1.139 +   * Adds data from a channel to the zip file. If the operation is performed
   1.140 +   * on the queue then the channel will be opened asynchronously, otherwise
   1.141 +   * the channel must support being opened synchronously.
   1.142 +   *
   1.143 +   * @param aZipEntry the path of the file entry
   1.144 +   * @param aModTime the modification time of the entry in microseconds
   1.145 +   * @param aCompression the compression level, 0 is no compression, 9 is best
   1.146 +   * @param aChannel the channel to get the data from
   1.147 +   * @param aQueue adds the operation to the background queue. Will be
   1.148 +   *        performed when processQueue is called.
   1.149 +   *
   1.150 +   * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened
   1.151 +   * @throws NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the zip
   1.152 +   * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress
   1.153 +   */
   1.154 +  void addEntryChannel(in AUTF8String aZipEntry, in PRTime aModTime,
   1.155 +                       in int32_t aCompression, in nsIChannel aChannel,
   1.156 +                       in boolean aQueue);
   1.157 +
   1.158 +  /**
   1.159 +   * Adds data from an input stream to the zip file.
   1.160 +   *
   1.161 +   * @param aZipEntry the path of the file entry
   1.162 +   * @param aModTime the modification time of the entry in microseconds
   1.163 +   * @param aCompression the compression level, 0 is no compression, 9 is best
   1.164 +   * @param aStream the input stream to get the data from
   1.165 +   * @param aQueue adds the operation to the background queue. Will be
   1.166 +   *        performed when processQueue is called.
   1.167 +   *
   1.168 +   * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened
   1.169 +   * @throws NS_ERROR_FILE_ALREADY_EXISTS if the path already exists in the zip
   1.170 +   * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress
   1.171 +   */
   1.172 +  void addEntryStream(in AUTF8String aZipEntry, in PRTime aModTime,
   1.173 +                      in int32_t aCompression, in nsIInputStream aStream,
   1.174 +                      in boolean aQueue);
   1.175 +
   1.176 +  /**
   1.177 +   * Removes an existing entry from the zip file.
   1.178 +   *
   1.179 +   * @param aZipEntry the path of the entry to be removed
   1.180 +   * @param aQueue adds the operation to the background queue. Will be
   1.181 +   *        performed when processQueue is called.
   1.182 +   *
   1.183 +   * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened
   1.184 +   * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress
   1.185 +   * @throws NS_ERROR_FILE_NOT_FOUND if no entry with the given path exists
   1.186 +   * @throws <other-error> on failure to update the zip file
   1.187 +   */
   1.188 +  void removeEntry(in AUTF8String aZipEntry, in boolean aQueue);
   1.189 +
   1.190 +  /**
   1.191 +   * Processes all queued items until complete or some error occurs. The
   1.192 +   * observer will be notified when the first operation starts and when the
   1.193 +   * last operation completes. Any failures will be passed to the observer.
   1.194 +   * The zip writer will be busy until the queue is complete or some error
   1.195 +   * halted processing of the queue early. In the event of an early failure,
   1.196 +   * remaining items will stay in the queue and calling processQueue will
   1.197 +   * continue.
   1.198 +   *
   1.199 +   * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened
   1.200 +   * @throws NS_ERROR_IN_PROGRESS if the queue is already in progress
   1.201 +   */
   1.202 +  void processQueue(in nsIRequestObserver aObserver, in nsISupports aContext);
   1.203 +
   1.204 +  /**
   1.205 +   * Closes the zip file.
   1.206 +   *
   1.207 +   * @throws NS_ERROR_NOT_INITIALIZED if no zip file has been opened
   1.208 +   * @throws NS_ERROR_IN_PROGRESS if another operation is currently in progress
   1.209 +   * @throws <other-error> on failure to complete the zip file
   1.210 +   */
   1.211 +  void close();
   1.212 +
   1.213 +  /**
   1.214 +   * Make all stored(uncompressed) files align to given alignment size.
   1.215 +   *
   1.216 +   * @param aAlignSize is the alignment size, valid values from 2 to 32768, and
   1.217 +            must be power of 2.
   1.218 +   *
   1.219 +   * @throws NS_ERROR_INVALID_ARG if aAlignSize is invalid
   1.220 +   * @throws <other-error> on failure to update the zip file
   1.221 +   */
   1.222 +  void alignStoredFiles(in uint16_t aAlignSize);
   1.223 +};

mercurial