michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: const DIRNAME = "test/"; michael@0: const time = Date.now(); michael@0: michael@0: function run_test() michael@0: { michael@0: // Copy in the test file. michael@0: var source = do_get_file("data/test.zip"); michael@0: source.copyTo(tmpFile.parent, tmpFile.leafName); michael@0: michael@0: // Open it and add something so the CDS is rewritten. michael@0: zipW.open(tmpFile, PR_RDWR | PR_APPEND); michael@0: zipW.addEntryDirectory(DIRNAME, time * PR_USEC_PER_MSEC, false); michael@0: do_check_true(zipW.hasEntry(DIRNAME)); michael@0: zipW.close(); michael@0: michael@0: var zipR = new ZipReader(tmpFile); michael@0: do_check_true(zipR.hasEntry(DIRNAME)); michael@0: zipR.close(); michael@0: michael@0: // Adding the directory would have added a fixed amount to the file size. michael@0: // Any difference suggests the CDS was written out incorrectly. michael@0: var extra = ZIP_FILE_HEADER_SIZE + ZIP_CDS_HEADER_SIZE + michael@0: (DIRNAME.length * 2) + (ZIP_EXTENDED_TIMESTAMP_SIZE * 2); michael@0: michael@0: do_check_eq(source.fileSize + extra, tmpFile.fileSize); michael@0: }