modules/libjar/zipwriter/test/unit/test_bug446708.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 function run_test() {
     2   var testBundle = do_get_file("data/test_bug446708");
     4   RecursivelyZipDirectory(testBundle);
     5 }
     7 // Add |file| to the zip. |path| is the current path for the file.
     8 function AddToZip(zipWriter, path, file)
     9 {
    10   var currentPath = path + file.leafName;
    12   if (file.isDirectory()) {
    13     currentPath += "/";
    14   }
    16   // THIS IS WHERE THE ERROR OCCURS, FOR THE FILE "st14-1.tiff" IN "test_bug446708"
    17   zipWriter.addEntryFile(currentPath, Ci.nsIZipWriter.COMPRESSION_DEFAULT, file, false);
    19   // if it's a dir, continue adding its contents recursively...
    20   if (file.isDirectory()) {
    21     var entries = file.QueryInterface(Components.interfaces.nsIFile).directoryEntries;
    22     while (entries.hasMoreElements()) {
    23       var entry = entries.getNext().QueryInterface(Components.interfaces.nsIFile);
    24       AddToZip(zipWriter, currentPath, entry);
    25     }
    26   }
    28   // ...otherwise, we're done
    29 }
    31 function RecursivelyZipDirectory(bundle)
    32 {
    33   zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
    34   AddToZip(zipW, "", bundle); 
    35   zipW.close();
    36 }

mercurial