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.

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

mercurial