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