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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libjar/zipwriter/test/unit/test_bug446708.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +function run_test() {
     1.5 +  var testBundle = do_get_file("data/test_bug446708");
     1.6 +
     1.7 +  RecursivelyZipDirectory(testBundle);
     1.8 +}
     1.9 +
    1.10 +// Add |file| to the zip. |path| is the current path for the file.
    1.11 +function AddToZip(zipWriter, path, file)
    1.12 +{
    1.13 +  var currentPath = path + file.leafName;
    1.14 +  
    1.15 +  if (file.isDirectory()) {
    1.16 +    currentPath += "/";
    1.17 +  }
    1.18 +  
    1.19 +  // THIS IS WHERE THE ERROR OCCURS, FOR THE FILE "st14-1.tiff" IN "test_bug446708"
    1.20 +  zipWriter.addEntryFile(currentPath, Ci.nsIZipWriter.COMPRESSION_DEFAULT, file, false);
    1.21 +  
    1.22 +  // if it's a dir, continue adding its contents recursively...
    1.23 +  if (file.isDirectory()) {
    1.24 +    var entries = file.QueryInterface(Components.interfaces.nsIFile).directoryEntries;
    1.25 +    while (entries.hasMoreElements()) {
    1.26 +      var entry = entries.getNext().QueryInterface(Components.interfaces.nsIFile);
    1.27 +      AddToZip(zipWriter, currentPath, entry);
    1.28 +    }
    1.29 +  }
    1.30 +  
    1.31 +  // ...otherwise, we're done
    1.32 +}
    1.33 +
    1.34 +function RecursivelyZipDirectory(bundle)
    1.35 +{
    1.36 +  zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
    1.37 +  AddToZip(zipW, "", bundle); 
    1.38 +  zipW.close();
    1.39 +}
    1.40 +

mercurial