Skip to content

Commit

Permalink
Add close method and close zip file aftering unzipping
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Nov 18, 2009
1 parent f8fccee commit 27b49bf
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions engines/rhino/lib/zip.js
Expand Up @@ -9,13 +9,19 @@ exports.unzip = function (source, target) {
if (!target)
target = system.fs.path(source).absolute().dirname();
target = system.fs.path(target);
return new exports.Unzip(source).forEach(function (entry) {
var targetPath = target.join(entry.getName());
if (entry.isDirectory())
return;
targetPath.dirname().mkdirs();
targetPath.write(entry.read('b'), 'b');
});
var unzip = new exports.Unzip(source);
try{
return unzip.forEach(function (entry) {
var targetPath = target.join(entry.getName());
if (entry.isDirectory())
return;
targetPath.dirname().mkdirs();
targetPath.write(entry.read('b'), 'b');
});
}
finally{
unzip.close();
}
};

exports.Unzip = function (path) {
Expand Down Expand Up @@ -50,6 +56,10 @@ exports.Unzip.prototype.forEach = function (block, context) {
}
};

exports.Unzip.prototype.close = function (mode, options) {
this._javaZipFile.close();
};

exports.Entry = function (javaZipFile, javaZipEntry) {
this._javaZipFile = javaZipFile;
this._javaZipEntry = javaZipEntry;
Expand Down

0 comments on commit 27b49bf

Please sign in to comment.