michael@0: function run_test() { michael@0: var testBundle = do_get_file("data/test_bug446708"); michael@0: michael@0: RecursivelyZipDirectory(testBundle); michael@0: } michael@0: michael@0: // Add |file| to the zip. |path| is the current path for the file. michael@0: function AddToZip(zipWriter, path, file) michael@0: { michael@0: var currentPath = path + file.leafName; michael@0: michael@0: if (file.isDirectory()) { michael@0: currentPath += "/"; michael@0: } michael@0: michael@0: // THIS IS WHERE THE ERROR OCCURS, FOR THE FILE "st14-1.tiff" IN "test_bug446708" michael@0: zipWriter.addEntryFile(currentPath, Ci.nsIZipWriter.COMPRESSION_DEFAULT, file, false); michael@0: michael@0: // if it's a dir, continue adding its contents recursively... michael@0: if (file.isDirectory()) { michael@0: var entries = file.QueryInterface(Components.interfaces.nsIFile).directoryEntries; michael@0: while (entries.hasMoreElements()) { michael@0: var entry = entries.getNext().QueryInterface(Components.interfaces.nsIFile); michael@0: AddToZip(zipWriter, currentPath, entry); michael@0: } michael@0: } michael@0: michael@0: // ...otherwise, we're done michael@0: } michael@0: michael@0: function RecursivelyZipDirectory(bundle) michael@0: { michael@0: zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE); michael@0: AddToZip(zipW, "", bundle); michael@0: zipW.close(); michael@0: } michael@0: