tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

head_zipwriter.js (1383B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 */
      5 
      6 const NS_ERROR_IN_PROGRESS = 2152398863;
      7 
      8 const PR_RDONLY = 0x01;
      9 const PR_WRONLY = 0x02;
     10 const PR_RDWR = 0x04;
     11 const PR_CREATE_FILE = 0x08;
     12 const PR_APPEND = 0x10;
     13 const PR_TRUNCATE = 0x20;
     14 const PR_SYNC = 0x40;
     15 const PR_EXCL = 0x80;
     16 
     17 const ZIP_EOCDR_HEADER_SIZE = 22;
     18 const ZIP_FILE_HEADER_SIZE = 30;
     19 const ZIP_CDS_HEADER_SIZE = 46;
     20 const ZIP_METHOD_STORE = 0;
     21 const ZIP_METHOD_DEFLATE = 8;
     22 const ZIP_EXTENDED_TIMESTAMP_SIZE = 9;
     23 
     24 const PR_USEC_PER_MSEC = 1000;
     25 const PR_USEC_PER_SEC = 1000000;
     26 const PR_MSEC_PER_SEC = 1000;
     27 
     28 const DATA_DIR = "data/";
     29 
     30 var ioSvc = Services.io;
     31 
     32 var ZipWriter = Components.Constructor(
     33  "@mozilla.org/zipwriter;1",
     34  "nsIZipWriter"
     35 );
     36 var ZipReader = Components.Constructor(
     37  "@mozilla.org/libjar/zip-reader;1",
     38  "nsIZipReader",
     39  "open"
     40 );
     41 
     42 var tmpDir = do_get_profile();
     43 var tmpFile = tmpDir.clone();
     44 tmpFile.append("zipwriter-test.zip");
     45 if (tmpFile.exists()) {
     46  tmpFile.remove(true);
     47 }
     48 
     49 var zipW = new ZipWriter();
     50 
     51 registerCleanupFunction(function () {
     52  try {
     53    zipW.close();
     54  } catch (e) {
     55    // Just ignore a failure here and attempt to delete the file anyway.
     56  }
     57  if (tmpFile.exists()) {
     58    tmpFile.remove(true);
     59  }
     60 });