Skip to content

Commit

Permalink
Fixed crc errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cthackers committed Apr 10, 2013
1 parent 03ba2f3 commit a9a05e5
Show file tree
Hide file tree
Showing 27 changed files with 10,417 additions and 343 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/adm-zip.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/scopes/scope_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

550 changes: 550 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

31 changes: 12 additions & 19 deletions adm-zip.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var fs = require("fs"),
buffer = require("buffer"),
pth = require("path");

fs.existsSync = fs.existsSync || pth.existsSync;
Expand All @@ -8,21 +7,21 @@ var ZipEntry = require("./zipEntry"),
ZipFile = require("./zipFile"),
Utils = require("./util");

module.exports = function(/*String*/inPath) {
module.exports = function(/*String*/input) {
var _zip = undefined,
_filename = "";

if (inPath && typeof inPath === "string") { // load zip file
if (fs.existsSync(inPath)) {
_filename = inPath;
_zip = new ZipFile(fs.readFileSync(inPath));
if (input && typeof input === "string") { // load zip file
if (fs.existsSync(input)) {
_filename = input;
_zip = new ZipFile(input, Utils.Constants.FILE);
} else {
throw Utils.Errors.INVALID_FILENAME;
}
} else if(inPath && Buffer.isBuffer(inPath)) { // load buffer
_zip = new ZipFile(inPath);
} else if(input && Buffer.isBuffer(input)) { // load buffer
_zip = new ZipFile(input, Utils.Constants.BUFFER);
} else { // create new zip file
_zip = new ZipFile();
_zip = new ZipFile(null, Utils.Constants.NONE);
}

function getEntry(/*Object*/entry) {
Expand All @@ -42,10 +41,6 @@ module.exports = function(/*String*/inPath) {
return null;
}

//process.on('uncaughtException', function (err) {
// console.log('Caught exception: ' + err);
//});

return {
/**
* Extracts the given entry from the archive and returns the content as a Buffer object
Expand All @@ -57,6 +52,7 @@ module.exports = function(/*String*/inPath) {
var item = getEntry(entry);
return item && item.getData() || null;
},

/**
* Asynchronous readFile
* @param entry ZipEntry object or String with the full path of the entry
Expand All @@ -72,6 +68,7 @@ module.exports = function(/*String*/inPath) {
callback(null,"getEntry failed for:" + entry)
}
},

/**
* Extracts the given entry from the archive and returns the content as plain text in the given encoding
* @param entry ZipEntry object or String with the full path of the entry
Expand All @@ -89,6 +86,7 @@ module.exports = function(/*String*/inPath) {
}
return "";
},

/**
* Asynchronous readAsText
* @param entry ZipEntry object or String with the full path of the entry
Expand Down Expand Up @@ -362,6 +360,7 @@ module.exports = function(/*String*/inPath) {
* Writes the newly created zip file to disk at the specified location or if a zip was opened and no ``targetFileName`` is provided, it will overwrite the opened zip
*
* @param targetFileName
* @param callback
*/
writeZip : function(/*String*/targetFileName, /*Function*/callback) {
if (arguments.length == 1) {
Expand Down Expand Up @@ -395,11 +394,5 @@ module.exports = function(/*String*/inPath) {
}
return _zip.toBuffer()
}

/*get lastError () {
var x = function() { console.log("2", arguments); };
x.prototype = 2
return x; //
} */
}
};
Loading

0 comments on commit a9a05e5

Please sign in to comment.