This commit is contained in:
life
2015-03-24 02:54:08 +08:00
parent 3e3b4b2924
commit e755043cb3
28 changed files with 4054 additions and 18 deletions

4
src/data/version Normal file
View File

@@ -0,0 +1,4 @@
{
"version": "0.1"
"updatedTime": ""
}

View File

64
src/node_modules/adm-zip/README.md generated vendored Normal file
View File

@@ -0,0 +1,64 @@
# ADM-ZIP for NodeJS
ADM-ZIP is a pure JavaScript implementation for zip data compression for [NodeJS](http://nodejs.org/).
# Installation
With [npm](http://npmjs.org) do:
$ npm install adm-zip
## What is it good for?
The library allows you to:
* decompress zip files directly to disk or in memory buffers
* compress files and store them to disk in .zip format or in compressed buffers
* update content of/add new/delete files from an existing .zip
# Dependencies
There are no other nodeJS libraries that ADM-ZIP is dependent of
# Examples
## Basic usage
```javascript
var AdmZip = require('adm-zip');
// reading archives
var zip = new AdmZip("./my_file.zip");
var zipEntries = zip.getEntries(); // an array of ZipEntry records
zipEntries.forEach(function(zipEntry) {
console.log(zipEntry.toString()); // outputs zip entries information
if (zipEntry.entryName == "my_file.txt") {
console.log(zipEntry.data.toString('utf8'));
}
});
// outputs the content of some_folder/my_file.txt
console.log(zip.readAsText("some_folder/my_file.txt"));
// extracts the specified file to the specified location
zip.extractEntryTo(/*entry name*/"some_folder/my_file.txt", /*target path*/"/home/me/tempfolder", /*maintainEntryPath*/false, /*overwrite*/true);
// extracts everything
zip.extractAllTo(/*target path*/"/home/me/zipcontent/", /*overwrite*/true);
// creating archives
var zip = new AdmZip();
// add file directly
zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here");
// add local file
zip.addLocalFile("/home/me/some_picture.png");
// get everything as a buffer
var willSendthis = zip.toBuffer();
// or write everything to disk
zip.writeZip(/*target file name*/"/home/me/files.zip");
// ... more examples in the wiki
```
For more detailed information please check out the [wiki](https://github.com/cthackers/adm-zip/wiki).
[![build status](https://secure.travis-ci.org/cthackers/adm-zip.png)](http://travis-ci.org/cthackers/adm-zip)

475
src/node_modules/adm-zip/adm-zip.js generated vendored Normal file
View File

@@ -0,0 +1,475 @@
var fs = require("fs"),
pth = require("path");
fs.existsSync = fs.existsSync || pth.existsSync;
var ZipEntry = require("./zipEntry"),
ZipFile = require("./zipFile"),
Utils = require("./util");
module.exports = function(/*String*/input) {
var _zip = undefined,
_filename = "";
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(input && Buffer.isBuffer(input)) { // load buffer
_zip = new ZipFile(input, Utils.Constants.BUFFER);
} else { // create new zip file
_zip = new ZipFile(null, Utils.Constants.NONE);
}
function getEntry(/*Object*/entry) {
if (entry && _zip) {
var item;
// If entry was given as a file name
if (typeof entry === "string")
item = _zip.getEntry(entry);
// if entry was given as a ZipEntry object
if (typeof entry === "object" && entry.entryName != undefined && entry.header != undefined)
item = _zip.getEntry(entry.entryName);
if (item) {
return item;
}
}
return null;
}
return {
/**
* Extracts the given entry from the archive and returns the content as a Buffer object
* @param entry ZipEntry object or String with the full path of the entry
*
* @return Buffer or Null in case of error
*/
readFile : function(/*Object*/entry) {
var item = getEntry(entry);
return item && item.getData() || null;
},
/**
* Asynchronous readFile
* @param entry ZipEntry object or String with the full path of the entry
* @param callback
*
* @return Buffer or Null in case of error
*/
readFileAsync : function(/*Object*/entry, /*Function*/callback) {
var item = getEntry(entry);
if (item) {
item.getDataAsync(callback);
} else {
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
* @param encoding Optional. If no encoding is specified utf8 is used
*
* @return String
*/
readAsText : function(/*Object*/entry, /*String - Optional*/encoding) {
var item = getEntry(entry);
if (item) {
var data = item.getData();
if (data && data.length) {
return data.toString(encoding || "utf8");
}
}
return "";
},
/**
* Asynchronous readAsText
* @param entry ZipEntry object or String with the full path of the entry
* @param callback
* @param encoding Optional. If no encoding is specified utf8 is used
*
* @return String
*/
readAsTextAsync : function(/*Object*/entry, /*Function*/callback, /*String - Optional*/encoding) {
var item = getEntry(entry);
if (item) {
item.getDataAsync(function(data) {
if (data && data.length) {
callback(data.toString(encoding || "utf8"));
} else {
callback("");
}
})
} else {
callback("");
}
},
/**
* Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
*
* @param entry
*/
deleteFile : function(/*Object*/entry) { // @TODO: test deleteFile
var item = getEntry(entry);
if (item) {
_zip.deleteEntry(item.entryName);
}
},
/**
* Adds a comment to the zip. The zip must be rewritten after adding the comment.
*
* @param comment
*/
addZipComment : function(/*String*/comment) { // @TODO: test addZipComment
_zip.comment = comment;
},
/**
* Returns the zip comment
*
* @return String
*/
getZipComment : function() {
return _zip.comment || '';
},
/**
* Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
* The comment cannot exceed 65535 characters in length
*
* @param entry
* @param comment
*/
addZipEntryComment : function(/*Object*/entry,/*String*/comment) {
var item = getEntry(entry);
if (item) {
item.comment = comment;
}
},
/**
* Returns the comment of the specified entry
*
* @param entry
* @return String
*/
getZipEntryComment : function(/*Object*/entry) {
var item = getEntry(entry);
if (item) {
return item.comment || '';
}
return ''
},
/**
* Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
*
* @param entry
* @param content
*/
updateFile : function(/*Object*/entry, /*Buffer*/content) {
var item = getEntry(entry);
if (item) {
item.setData(content);
}
},
/**
* Adds a file from the disk to the archive
*
* @param localPath
*/
addLocalFile : function(/*String*/localPath, /*String*/zipPath, /*String*/zipName) {
if (fs.existsSync(localPath)) {
if(zipPath){
zipPath=zipPath.split("\\").join("/");
if(zipPath.charAt(zipPath.length - 1) != "/"){
zipPath += "/";
}
}else{
zipPath="";
}
var p = localPath.split("\\").join("/").split("/").pop();
if(zipName){
this.addFile(zipPath+zipName, fs.readFileSync(localPath), "", 0)
}else{
this.addFile(zipPath+p, fs.readFileSync(localPath), "", 0)
}
} else {
throw Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath);
}
},
/**
* Adds a local directory and all its nested files and directories to the archive
*
* @param localPath
* @param zipPath optional path inside zip
* @param filter optional RegExp or Function if files match will
* be included.
*/
addLocalFolder : function(/*String*/localPath, /*String*/zipPath, /*RegExp|Function*/filter) {
if (filter === undefined) {
filter = function() { return true; };
} else if (filter instanceof RegExp) {
filter = function(filter) {
return function(filename) {
return filter.test(filename);
}
}(filter);
}
if(zipPath){
zipPath=zipPath.split("\\").join("/");
if(zipPath.charAt(zipPath.length - 1) != "/"){
zipPath += "/";
}
}else{
zipPath="";
}
localPath = localPath.split("\\").join("/"); //windows fix
localPath = pth.normalize(localPath);
if (localPath.charAt(localPath.length - 1) != "/")
localPath += "/";
if (fs.existsSync(localPath)) {
var items = Utils.findFiles(localPath),
self = this;
if (items.length) {
items.forEach(function(path) {
var p = path.split("\\").join("/").replace( new RegExp(localPath, 'i'), ""); //windows fix
if (filter(p)) {
if (p.charAt(p.length - 1) !== "/") {
self.addFile(zipPath+p, fs.readFileSync(path), "", 0)
} else {
self.addFile(zipPath+p, new Buffer(0), "", 0)
}
}
});
}
} else {
throw Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath);
}
},
/**
* Allows you to create a entry (file or directory) in the zip file.
* If you want to create a directory the entryName must end in / and a null buffer should be provided.
* Comment and attributes are optional
*
* @param entryName
* @param content
* @param comment
* @param attr
*/
addFile : function(/*String*/entryName, /*Buffer*/content, /*String*/comment, /*Number*/attr) {
var entry = new ZipEntry();
entry.entryName = entryName;
entry.comment = comment || "";
entry.attr = attr || 438; //0666;
if (entry.isDirectory && content.length) {
// throw Utils.Errors.DIRECTORY_CONTENT_ERROR;
}
entry.setData(content);
_zip.setEntry(entry);
},
/**
* Returns an array of ZipEntry objects representing the files and folders inside the archive
*
* @return Array
*/
getEntries : function() {
if (_zip) {
return _zip.entries;
} else {
return [];
}
},
/**
* Returns a ZipEntry object representing the file or folder specified by ``name``.
*
* @param name
* @return ZipEntry
*/
getEntry : function(/*String*/name) {
return getEntry(name);
},
/**
* Extracts the given entry to the given targetPath
* If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
*
* @param entry ZipEntry object or String with the full path of the entry
* @param targetPath Target folder where to write the file
* @param maintainEntryPath If maintainEntryPath is true and the entry is inside a folder, the entry folder
* will be created in targetPath as well. Default is TRUE
* @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
* Default is FALSE
*
* @return Boolean
*/
extractEntryTo : function(/*Object*/entry, /*String*/targetPath, /*Boolean*/maintainEntryPath, /*Boolean*/overwrite) {
overwrite = overwrite || false;
maintainEntryPath = typeof maintainEntryPath == "undefined" ? true : maintainEntryPath;
var item = getEntry(entry);
if (!item) {
throw Utils.Errors.NO_ENTRY;
}
var target = pth.resolve(targetPath, maintainEntryPath ? item.entryName : pth.basename(item.entryName));
if (item.isDirectory) {
target = pth.resolve(target, "..");
var children = _zip.getEntryChildren(item);
children.forEach(function(child) {
if (child.isDirectory) return;
var content = child.getData();
if (!content) {
throw Utils.Errors.CANT_EXTRACT_FILE;
}
Utils.writeFileTo(pth.resolve(targetPath, maintainEntryPath ? child.entryName : child.entryName.substr(item.entryName.length)), content, overwrite);
});
return true;
}
var content = item.getData();
if (!content) throw Utils.Errors.CANT_EXTRACT_FILE;
if (fs.existsSync(target) && !overwrite) {
throw Utils.Errors.CANT_OVERRIDE;
}
Utils.writeFileTo(target, content, overwrite);
return true;
},
/**
* Extracts the entire archive to the given location
*
* @param targetPath Target location
* @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
* Default is FALSE
*/
extractAllTo : function(/*String*/targetPath, /*Boolean*/overwrite) {
overwrite = overwrite || false;
if (!_zip) {
throw Utils.Errors.NO_ZIP;
}
_zip.entries.forEach(function(entry) {
if (entry.isDirectory) {
Utils.makeDir(pth.resolve(targetPath, entry.entryName.toString()));
return;
}
var content = entry.getData();
if (!content) {
throw Utils.Errors.CANT_EXTRACT_FILE + "2";
}
Utils.writeFileTo(pth.resolve(targetPath, entry.entryName.toString()), content, overwrite);
})
},
/**
* Asynchronous extractAllTo
*
* @param targetPath Target location
* @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
* Default is FALSE
* @param callback
*/
extractAllToAsync : function(/*String*/targetPath, /*Boolean*/overwrite, /*Function*/callback) {
overwrite = overwrite || false;
if (!_zip) {
callback(new Error(Utils.Errors.NO_ZIP));
return;
}
var entries = _zip.entries;
var i = entries.length;
entries.forEach(function(entry) {
if(i <= 0) return; // Had an error already
if (entry.isDirectory) {
Utils.makeDir(pth.resolve(targetPath, entry.entryName.toString()));
if(--i == 0)
callback(undefined);
return;
}
entry.getDataAsync(function(content) {
if(i <= 0) return;
if (!content) {
i = 0;
callback(new Error(Utils.Errors.CANT_EXTRACT_FILE + "2"));
return;
}
Utils.writeFileToAsync(pth.resolve(targetPath, entry.entryName.toString()), content, overwrite, function(succ) {
if(i <= 0) return;
if(!succ) {
i = 0;
callback(new Error('Unable to write'));
return;
}
if(--i == 0)
callback(undefined);
});
});
})
},
/**
* 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) {
if (typeof targetFileName == "function") {
callback = targetFileName;
targetFileName = "";
}
}
if (!targetFileName && _filename) {
targetFileName = _filename;
}
if (!targetFileName) return;
var zipData = _zip.compressToBuffer();
if (zipData) {
var ok = Utils.writeFileTo(targetFileName, zipData, true);
if (typeof callback == 'function') callback(!ok? new Error("failed"): null, "");
}
},
/**
* Returns the content of the entire zip file as a Buffer object
*
* @return Buffer
*/
toBuffer : function(/*Function*/onSuccess,/*Function*/onFail,/*Function*/onItemStart,/*Function*/onItemEnd) {
this.valueOf = 2;
if (typeof onSuccess == "function") {
_zip.toAsyncBuffer(onSuccess,onFail,onItemStart,onItemEnd);
return null;
}
return _zip.compressToBuffer()
}
}
};

261
src/node_modules/adm-zip/headers/entryHeader.js generated vendored Normal file
View File

@@ -0,0 +1,261 @@
var Utils = require("../util"),
Constants = Utils.Constants;
/* The central directory file header */
module.exports = function () {
var _verMade = 0x0A,
_version = 0x0A,
_flags = 0,
_method = 0,
_time = 0,
_crc = 0,
_compressedSize = 0,
_size = 0,
_fnameLen = 0,
_extraLen = 0,
_comLen = 0,
_diskStart = 0,
_inattr = 0,
_attr = 0,
_offset = 0;
var _dataHeader = {};
function setTime(val) {
var val = new Date(val);
_time = (val.getFullYear() - 1980 & 0x7f) << 25 // b09-16 years from 1980
| (val.getMonth() + 1) << 21 // b05-08 month
| val.getDay() << 16 // b00-04 hour
// 2 bytes time
| val.getHours() << 11 // b11-15 hour
| val.getMinutes() << 5 // b05-10 minute
| val.getSeconds() >> 1; // b00-04 seconds divided by 2
}
setTime(+new Date());
return {
get made () { return _verMade; },
set made (val) { _verMade = val; },
get version () { return _version; },
set version (val) { _version = val },
get flags () { return _flags },
set flags (val) { _flags = val; },
get method () { return _method; },
set method (val) { _method = val; },
get time () { return new Date(
((_time >> 25) & 0x7f) + 1980,
((_time >> 21) & 0x0f) - 1,
(_time >> 16) & 0x1f,
(_time >> 11) & 0x1f,
(_time >> 5) & 0x3f,
(_time & 0x1f) << 1
);
},
set time (val) {
setTime(val);
},
get crc () { return _crc; },
set crc (val) { _crc = val; },
get compressedSize () { return _compressedSize; },
set compressedSize (val) { _compressedSize = val; },
get size () { return _size; },
set size (val) { _size = val; },
get fileNameLength () { return _fnameLen; },
set fileNameLength (val) { _fnameLen = val; },
get extraLength () { return _extraLen },
set extraLength (val) { _extraLen = val; },
get commentLength () { return _comLen },
set commentLength (val) { _comLen = val },
get diskNumStart () { return _diskStart },
set diskNumStart (val) { _diskStart = val },
get inAttr () { return _inattr },
set inAttr (val) { _inattr = val },
get attr () { return _attr },
set attr (val) { _attr = val },
get offset () { return _offset },
set offset (val) { _offset = val },
get encripted () { return (_flags & 1) == 1 },
get entryHeaderSize () {
return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
},
get realDataOffset () {
return _offset + Constants.LOCHDR + _dataHeader.fnameLen + _dataHeader.extraLen;
},
get dataHeader () {
return _dataHeader;
},
loadDataHeaderFromBinary : function(/*Buffer*/input) {
var data = input.slice(_offset, _offset + Constants.LOCHDR);
// 30 bytes and should start with "PK\003\004"
if (data.readUInt32LE(0) != Constants.LOCSIG) {
throw Utils.Errors.INVALID_LOC;
}
_dataHeader = {
// version needed to extract
version : data.readUInt16LE(Constants.LOCVER),
// general purpose bit flag
flags : data.readUInt16LE(Constants.LOCFLG),
// compression method
method : data.readUInt16LE(Constants.LOCHOW),
// modification time (2 bytes time, 2 bytes date)
time : data.readUInt32LE(Constants.LOCTIM),
// uncompressed file crc-32 value
crc : data.readUInt32LE(Constants.LOCCRC),
// compressed size
compressedSize : data.readUInt32LE(Constants.LOCSIZ),
// uncompressed size
size : data.readUInt32LE(Constants.LOCLEN),
// filename length
fnameLen : data.readUInt16LE(Constants.LOCNAM),
// extra field length
extraLen : data.readUInt16LE(Constants.LOCEXT)
}
},
loadFromBinary : function(/*Buffer*/data) {
// data should be 46 bytes and start with "PK 01 02"
if (data.length != Constants.CENHDR || data.readUInt32LE(0) != Constants.CENSIG) {
throw Utils.Errors.INVALID_CEN;
}
// version made by
_verMade = data.readUInt16LE(Constants.CENVEM);
// version needed to extract
_version = data.readUInt16LE(Constants.CENVER);
// encrypt, decrypt flags
_flags = data.readUInt16LE(Constants.CENFLG);
// compression method
_method = data.readUInt16LE(Constants.CENHOW);
// modification time (2 bytes time, 2 bytes date)
_time = data.readUInt32LE(Constants.CENTIM);
// uncompressed file crc-32 value
_crc = data.readUInt32LE(Constants.CENCRC);
// compressed size
_compressedSize = data.readUInt32LE(Constants.CENSIZ);
// uncompressed size
_size = data.readUInt32LE(Constants.CENLEN);
// filename length
_fnameLen = data.readUInt16LE(Constants.CENNAM);
// extra field length
_extraLen = data.readUInt16LE(Constants.CENEXT);
// file comment length
_comLen = data.readUInt16LE(Constants.CENCOM);
// volume number start
_diskStart = data.readUInt16LE(Constants.CENDSK);
// internal file attributes
_inattr = data.readUInt16LE(Constants.CENATT);
// external file attributes
_attr = data.readUInt32LE(Constants.CENATX);
// LOC header offset
_offset = data.readUInt32LE(Constants.CENOFF);
},
dataHeaderToBinary : function() {
// LOC header size (30 bytes)
var data = new Buffer(Constants.LOCHDR);
// "PK\003\004"
data.writeUInt32LE(Constants.LOCSIG, 0);
// version needed to extract
data.writeUInt16LE(_version, Constants.LOCVER);
// general purpose bit flag
data.writeUInt16LE(_flags, Constants.LOCFLG);
// compression method
data.writeUInt16LE(_method, Constants.LOCHOW);
// modification time (2 bytes time, 2 bytes date)
data.writeUInt32LE(_time, Constants.LOCTIM);
// uncompressed file crc-32 value
data.writeUInt32LE(_crc, Constants.LOCCRC);
// compressed size
data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
// uncompressed size
data.writeUInt32LE(_size, Constants.LOCLEN);
// filename length
data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
// extra field length
data.writeUInt16LE(_extraLen, Constants.LOCEXT);
return data;
},
entryHeaderToBinary : function() {
// CEN header size (46 bytes)
var data = new Buffer(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
// "PK\001\002"
data.writeUInt32LE(Constants.CENSIG, 0);
// version made by
data.writeUInt16LE(_verMade, Constants.CENVEM);
// version needed to extract
data.writeUInt16LE(_version, Constants.CENVER);
// encrypt, decrypt flags
data.writeUInt16LE(_flags, Constants.CENFLG);
// compression method
data.writeUInt16LE(_method, Constants.CENHOW);
// modification time (2 bytes time, 2 bytes date)
data.writeUInt32LE(_time, Constants.CENTIM);
// uncompressed file crc-32 value
data.writeInt32LE(_crc, Constants.CENCRC, true);
// compressed size
data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
// uncompressed size
data.writeUInt32LE(_size, Constants.CENLEN);
// filename length
data.writeUInt16LE(_fnameLen, Constants.CENNAM);
// extra field length
data.writeUInt16LE(_extraLen, Constants.CENEXT);
// file comment length
data.writeUInt16LE(_comLen, Constants.CENCOM);
// volume number start
data.writeUInt16LE(_diskStart, Constants.CENDSK);
// internal file attributes
data.writeUInt16LE(_inattr, Constants.CENATT);
// external file attributes
data.writeUInt32LE(_attr, Constants.CENATX);
// LOC header offset
data.writeUInt32LE(_offset, Constants.CENOFF);
// fill all with
data.fill(0x00, Constants.CENHDR);
return data;
},
toString : function() {
return '{\n' +
'\t"made" : ' + _verMade + ",\n" +
'\t"version" : ' + _version + ",\n" +
'\t"flags" : ' + _flags + ",\n" +
'\t"method" : ' + Utils.methodToString(_method) + ",\n" +
'\t"time" : ' + _time + ",\n" +
'\t"crc" : 0x' + _crc.toString(16).toUpperCase() + ",\n" +
'\t"compressedSize" : ' + _compressedSize + " bytes,\n" +
'\t"size" : ' + _size + " bytes,\n" +
'\t"fileNameLength" : ' + _fnameLen + ",\n" +
'\t"extraLength" : ' + _extraLen + " bytes,\n" +
'\t"commentLength" : ' + _comLen + " bytes,\n" +
'\t"diskNumStart" : ' + _diskStart + ",\n" +
'\t"inAttr" : ' + _inattr + ",\n" +
'\t"attr" : ' + _attr + ",\n" +
'\t"offset" : ' + _offset + ",\n" +
'\t"entryHeaderSize" : ' + (Constants.CENHDR + _fnameLen + _extraLen + _comLen) + " bytes\n" +
'}';
}
}
};

2
src/node_modules/adm-zip/headers/index.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
exports.EntryHeader = require("./entryHeader");
exports.MainHeader = require("./mainHeader");

80
src/node_modules/adm-zip/headers/mainHeader.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
var Utils = require("../util"),
Constants = Utils.Constants;
/* The entries in the end of central directory */
module.exports = function () {
var _volumeEntries = 0,
_totalEntries = 0,
_size = 0,
_offset = 0,
_commentLength = 0;
return {
get diskEntries () { return _volumeEntries },
set diskEntries (/*Number*/val) { _volumeEntries = _totalEntries = val; },
get totalEntries () { return _totalEntries },
set totalEntries (/*Number*/val) { _totalEntries = _volumeEntries = val; },
get size () { return _size },
set size (/*Number*/val) { _size = val; },
get offset () { return _offset },
set offset (/*Number*/val) { _offset = val; },
get commentLength () { return _commentLength },
set commentLength (/*Number*/val) { _commentLength = val; },
get mainHeaderSize () {
return Constants.ENDHDR + _commentLength;
},
loadFromBinary : function(/*Buffer*/data) {
// data should be 22 bytes and start with "PK 05 06"
if (data.length != Constants.ENDHDR || data.readUInt32LE(0) != Constants.ENDSIG)
throw Utils.Errors.INVALID_END;
// number of entries on this volume
_volumeEntries = data.readUInt16LE(Constants.ENDSUB);
// total number of entries
_totalEntries = data.readUInt16LE(Constants.ENDTOT);
// central directory size in bytes
_size = data.readUInt32LE(Constants.ENDSIZ);
// offset of first CEN header
_offset = data.readUInt32LE(Constants.ENDOFF);
// zip file comment length
_commentLength = data.readUInt16LE(Constants.ENDCOM);
},
toBinary : function() {
var b = new Buffer(Constants.ENDHDR + _commentLength);
// "PK 05 06" signature
b.writeUInt32LE(Constants.ENDSIG, 0);
b.writeUInt32LE(0, 4);
// number of entries on this volume
b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
// total number of entries
b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
// central directory size in bytes
b.writeUInt32LE(_size, Constants.ENDSIZ);
// offset of first CEN header
b.writeUInt32LE(_offset, Constants.ENDOFF);
// zip file comment length
b.writeUInt16LE(_commentLength, Constants.ENDCOM);
// fill comment memory with spaces so no garbage is left there
b.fill(" ", Constants.ENDHDR);
return b;
},
toString : function() {
return '{\n' +
'\t"diskEntries" : ' + _volumeEntries + ",\n" +
'\t"totalEntries" : ' + _totalEntries + ",\n" +
'\t"size" : ' + _size + " bytes,\n" +
'\t"offset" : 0x' + _offset.toString(16).toUpperCase() + ",\n" +
'\t"commentLength" : 0x' + _commentLength + "\n" +
'}';
}
}
};

1578
src/node_modules/adm-zip/methods/deflater.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

2
src/node_modules/adm-zip/methods/index.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
exports.Deflater = require("./deflater");
exports.Inflater = require("./inflater");

448
src/node_modules/adm-zip/methods/inflater.js generated vendored Normal file
View File

@@ -0,0 +1,448 @@
var Buffer = require("buffer").Buffer;
function JSInflater(/*Buffer*/input) {
var WSIZE = 0x8000,
slide = new Buffer(0x10000),
windowPos = 0,
fixedTableList = null,
fixedTableDist,
fixedLookup,
bitBuf = 0,
bitLen = 0,
method = -1,
eof = false,
copyLen = 0,
copyDist = 0,
tblList, tblDist, bitList, bitdist,
inputPosition = 0,
MASK_BITS = [0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff],
LENS = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0],
LEXT = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99],
DISTS = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577],
DEXT = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13],
BITORDER = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
function HuffTable(clen, cnum, cval, blist, elist, lookupm) {
this.status = 0;
this.root = null;
this.maxbit = 0;
var el, f, tail,
offsets = [],
countTbl = [],
sTbl = [],
values = [],
tentry = {extra: 0, bitcnt: 0, lbase: 0, next: null};
tail = this.root = null;
for(var i = 0; i < 0x11; i++) { countTbl[i] = 0; sTbl[i] = 0; offsets[i] = 0; }
for(i = 0; i < 0x120; i++) values[i] = 0;
el = cnum > 256 ? clen[256] : 16;
var pidx = -1;
while (++pidx < cnum) countTbl[clen[pidx]]++;
if(countTbl[0] == cnum) return;
for(var j = 1; j <= 16; j++) if(countTbl[j] != 0) break;
var bitLen = j;
for(i = 16; i != 0; i--) if(countTbl[i] != 0) break;
var maxLen = i;
lookupm < j && (lookupm = j);
var dCodes = 1 << j;
for(; j < i; j++, dCodes <<= 1)
if((dCodes -= countTbl[j]) < 0) {
this.status = 2;
this.maxbit = lookupm;
return;
}
if((dCodes -= countTbl[i]) < 0) {
this.status = 2;
this.maxbit = lookupm;
return;
}
countTbl[i] += dCodes;
offsets[1] = j = 0;
pidx = 1;
var xp = 2;
while(--i > 0) offsets[xp++] = (j += countTbl[pidx++]);
pidx = 0;
i = 0;
do {
(j = clen[pidx++]) && (values[offsets[j]++] = i);
} while(++i < cnum);
cnum = offsets[maxLen];
offsets[0] = i = 0;
pidx = 0;
var level = -1,
w = sTbl[0] = 0,
cnode = null,
tblCnt = 0,
tblStack = [];
for(; bitLen <= maxLen; bitLen++) {
var kccnt = countTbl[bitLen];
while(kccnt-- > 0) {
while(bitLen > w + sTbl[1 + level]) {
w += sTbl[1 + level];
level++;
tblCnt = (tblCnt = maxLen - w) > lookupm ? lookupm : tblCnt;
if((f = 1 << (j = bitLen - w)) > kccnt + 1) {
f -= kccnt + 1;
xp = bitLen;
while(++j < tblCnt) {
if((f <<= 1) <= countTbl[++xp]) break;
f -= countTbl[xp];
}
}
if(w + j > el && w < el) j = el - w;
tblCnt = 1 << j;
sTbl[1 + level] = j;
cnode = [];
while (cnode.length < tblCnt) cnode.push({extra: 0, bitcnt: 0, lbase: 0, next: null});
if (tail == null) {
tail = this.root = {next:null, list:null};
} else {
tail = tail.next = {next:null, list:null}
}
tail.next = null;
tail.list = cnode;
tblStack[level] = cnode;
if(level > 0) {
offsets[level] = i;
tentry.bitcnt = sTbl[level];
tentry.extra = 16 + j;
tentry.next = cnode;
j = (i & ((1 << w) - 1)) >> (w - sTbl[level]);
tblStack[level-1][j].extra = tentry.extra;
tblStack[level-1][j].bitcnt = tentry.bitcnt;
tblStack[level-1][j].lbase = tentry.lbase;
tblStack[level-1][j].next = tentry.next;
}
}
tentry.bitcnt = bitLen - w;
if(pidx >= cnum)
tentry.extra = 99;
else if(values[pidx] < cval) {
tentry.extra = (values[pidx] < 256 ? 16 : 15);
tentry.lbase = values[pidx++];
} else {
tentry.extra = elist[values[pidx] - cval];
tentry.lbase = blist[values[pidx++] - cval];
}
f = 1 << (bitLen - w);
for(j = i >> w; j < tblCnt; j += f) {
cnode[j].extra = tentry.extra;
cnode[j].bitcnt = tentry.bitcnt;
cnode[j].lbase = tentry.lbase;
cnode[j].next = tentry.next;
}
for(j = 1 << (bitLen - 1); (i & j) != 0; j >>= 1)
i ^= j;
i ^= j;
while((i & ((1 << w) - 1)) != offsets[level]) {
w -= sTbl[level];
level--;
}
}
}
this.maxbit = sTbl[1];
this.status = ((dCodes != 0 && maxLen != 1) ? 1 : 0);
}
function addBits(n) {
while(bitLen < n) {
bitBuf |= input[inputPosition++] << bitLen;
bitLen += 8;
}
return bitBuf;
}
function cutBits(n) {
bitLen -= n;
return bitBuf >>= n;
}
function maskBits(n) {
while(bitLen < n) {
bitBuf |= input[inputPosition++] << bitLen;
bitLen += 8;
}
var res = bitBuf & MASK_BITS[n];
bitBuf >>= n;
bitLen -= n;
return res;
}
function codes(buff, off, size) {
var e, t;
if(size == 0) return 0;
var n = 0;
for(;;) {
t = tblList.list[addBits(bitList) & MASK_BITS[bitList]];
e = t.extra;
while(e > 16) {
if(e == 99) return -1;
cutBits(t.bitcnt);
e -= 16;
t = t.next[addBits(e) & MASK_BITS[e]];
e = t.extra;
}
cutBits(t.bitcnt);
if(e == 16) {
windowPos &= WSIZE - 1;
buff[off + n++] = slide[windowPos++] = t.lbase;
if(n == size) return size;
continue;
}
if(e == 15) break;
copyLen = t.lbase + maskBits(e);
t = tblDist.list[addBits(bitdist) & MASK_BITS[bitdist]];
e = t.extra;
while(e > 16) {
if(e == 99) return -1;
cutBits(t.bitcnt);
e -= 16;
t = t.next[addBits(e) & MASK_BITS[e]];
e = t.extra
}
cutBits(t.bitcnt);
copyDist = windowPos - t.lbase - maskBits(e);
while(copyLen > 0 && n < size) {
copyLen--;
copyDist &= WSIZE - 1;
windowPos &= WSIZE - 1;
buff[off + n++] = slide[windowPos++] = slide[copyDist++];
}
if(n == size) return size;
}
method = -1; // done
return n;
}
function stored(buff, off, size) {
cutBits(bitLen & 7);
var n = maskBits(0x10);
if(n != ((~maskBits(0x10)) & 0xffff)) return -1;
copyLen = n;
n = 0;
while(copyLen > 0 && n < size) {
copyLen--;
windowPos &= WSIZE - 1;
buff[off + n++] = slide[windowPos++] = maskBits(8);
}
if(copyLen == 0) method = -1;
return n;
}
function fixed(buff, off, size) {
var fixed_bd = 0;
if(fixedTableList == null) {
var lengths = [];
for(var symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8;
for(; symbol < 256; symbol++) lengths[symbol] = 9;
for(; symbol < 280; symbol++) lengths[symbol] = 7;
for(; symbol < 288; symbol++) lengths[symbol] = 8;
fixedLookup = 7;
var htbl = new HuffTable(lengths, 288, 257, LENS, LEXT, fixedLookup);
if(htbl.status != 0) return -1;
fixedTableList = htbl.root;
fixedLookup = htbl.maxbit;
for(symbol = 0; symbol < 30; symbol++) lengths[symbol] = 5;
fixed_bd = 5;
htbl = new HuffTable(lengths, 30, 0, DISTS, DEXT, fixed_bd);
if(htbl.status > 1) {
fixedTableList = null;
return -1;
}
fixedTableDist = htbl.root;
fixed_bd = htbl.maxbit;
}
tblList = fixedTableList;
tblDist = fixedTableDist;
bitList = fixedLookup;
bitdist = fixed_bd;
return codes(buff, off, size);
}
function dynamic(buff, off, size) {
var ll = new Array(0x023C);
for (var m = 0; m < 0x023C; m++) ll[m] = 0;
var llencnt = 257 + maskBits(5),
dcodescnt = 1 + maskBits(5),
bitlencnt = 4 + maskBits(4);
if(llencnt > 286 || dcodescnt > 30) return -1;
for(var j = 0; j < bitlencnt; j++) ll[BITORDER[j]] = maskBits(3);
for(; j < 19; j++) ll[BITORDER[j]] = 0;
// build decoding table for trees--single level, 7 bit lookup
bitList = 7;
var hufTable = new HuffTable(ll, 19, 19, null, null, bitList);
if(hufTable.status != 0)
return -1; // incomplete code set
tblList = hufTable.root;
bitList = hufTable.maxbit;
var lencnt = llencnt + dcodescnt,
i = 0,
lastLen = 0;
while(i < lencnt) {
var hufLcode = tblList.list[addBits(bitList) & MASK_BITS[bitList]];
j = hufLcode.bitcnt;
cutBits(j);
j = hufLcode.lbase;
if(j < 16)
ll[i++] = lastLen = j;
else if(j == 16) {
j = 3 + maskBits(2);
if(i + j > lencnt) return -1;
while(j-- > 0) ll[i++] = lastLen;
} else if(j == 17) {
j = 3 + maskBits(3);
if(i + j > lencnt) return -1;
while(j-- > 0) ll[i++] = 0;
lastLen = 0;
} else {
j = 11 + maskBits(7);
if(i + j > lencnt) return -1;
while(j-- > 0) ll[i++] = 0;
lastLen = 0;
}
}
bitList = 9;
hufTable = new HuffTable(ll, llencnt, 257, LENS, LEXT, bitList);
bitList == 0 && (hufTable.status = 1);
if (hufTable.status != 0) return -1;
tblList = hufTable.root;
bitList = hufTable.maxbit;
for(i = 0; i < dcodescnt; i++) ll[i] = ll[i + llencnt];
bitdist = 6;
hufTable = new HuffTable(ll, dcodescnt, 0, DISTS, DEXT, bitdist);
tblDist = hufTable.root;
bitdist = hufTable.maxbit;
if((bitdist == 0 && llencnt > 257) || hufTable.status != 0) return -1;
return codes(buff, off, size);
}
return {
inflate : function(/*Buffer*/outputBuffer) {
tblList = null;
var size = outputBuffer.length,
offset = 0, i;
while(offset < size) {
if(eof && method == -1) return;
if(copyLen > 0) {
if(method != 0) {
while(copyLen > 0 && offset < size) {
copyLen--;
copyDist &= WSIZE - 1;
windowPos &= WSIZE - 1;
outputBuffer[offset++] = (slide[windowPos++] = slide[copyDist++]);
}
} else {
while(copyLen > 0 && offset < size) {
copyLen--;
windowPos &= WSIZE - 1;
outputBuffer[offset++] = (slide[windowPos++] = maskBits(8));
}
copyLen == 0 && (method = -1); // done
}
if (offset == size) return;
}
if(method == -1) {
if(eof) break;
eof = maskBits(1) != 0;
method = maskBits(2);
tblList = null;
copyLen = 0;
}
switch(method) {
case 0: i = stored(outputBuffer, offset, size - offset); break;
case 1: i = tblList != null ? codes(outputBuffer, offset, size - offset) : fixed(outputBuffer, offset, size - offset); break;
case 2: i = tblList != null ? codes(outputBuffer, offset, size - offset) : dynamic(outputBuffer, offset, size - offset); break;
default: i = -1; break;
}
if(i == -1) return;
offset += i;
}
}
};
}
module.exports = function(/*Buffer*/inbuf) {
var zlib = require("zlib");
return {
inflateAsync : function(/*Function*/callback) {
var tmp = zlib.createInflateRaw(),
parts = [], total = 0;
tmp.on('data', function(data) {
parts.push(data);
total += data.length;
});
tmp.on('end', function() {
var buf = new Buffer(total), written = 0;
buf.fill(0);
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
part.copy(buf, written);
written += part.length;
}
callback && callback(buf);
});
tmp.end(inbuf)
},
inflate : function(/*Buffer*/outputBuffer) {
var x = {
x: new JSInflater(inbuf)
};
x.x.inflate(outputBuffer);
delete(x.x);
}
}
};

66
src/node_modules/adm-zip/package.json generated vendored Normal file
View File

@@ -0,0 +1,66 @@
{
"name": "adm-zip",
"version": "0.4.7",
"description": "A Javascript implementation of zip for nodejs. Allows user to create or extract zip files both in memory or to/from disk",
"keywords": [
"zip",
"methods",
"archive",
"unzip"
],
"homepage": "http://github.com/cthackers/adm-zip",
"author": {
"name": "Nasca Iacob",
"email": "sy@another-d-mention.ro",
"url": "https://github.com/cthackers"
},
"bugs": {
"url": "https://github.com/cthackers/adm-zip/issues",
"email": "sy@another-d-mention.ro"
},
"licenses": [
{
"type": "MIT",
"url": "https://raw.github.com/cthackers/adm-zip/master/MIT-LICENSE.txt"
}
],
"files": [
"adm-zip.js",
"headers",
"methods",
"util",
"zipEntry.js",
"zipFile.js"
],
"main": "adm-zip.js",
"repository": {
"type": "git",
"url": "https://github.com/cthackers/adm-zip.git"
},
"engines": {
"node": ">=0.3.0"
},
"gitHead": "6708a3e5788ff9e67ddba288397f7788a5c02855",
"_id": "adm-zip@0.4.7",
"scripts": {},
"_shasum": "8606c2cbf1c426ce8c8ec00174447fd49b6eafc1",
"_from": "adm-zip@",
"_resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz",
"_npmVersion": "2.5.1",
"_nodeVersion": "0.12.0",
"_npmUser": {
"name": "cthackers",
"email": "iacob.campia@gmail.com"
},
"maintainers": [
{
"name": "cthackers",
"email": "sy@another-d-mention.ro"
}
],
"dist": {
"shasum": "8606c2cbf1c426ce8c8ec00174447fd49b6eafc1",
"tarball": "http://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz"
},
"directories": {}
}

115
src/node_modules/adm-zip/util/constants.js generated vendored Normal file
View File

@@ -0,0 +1,115 @@
module.exports = {
/* The local file header */
LOCHDR : 30, // LOC header size
LOCSIG : 0x04034b50, // "PK\003\004"
LOCVER : 4, // version needed to extract
LOCFLG : 6, // general purpose bit flag
LOCHOW : 8, // compression method
LOCTIM : 10, // modification time (2 bytes time, 2 bytes date)
LOCCRC : 14, // uncompressed file crc-32 value
LOCSIZ : 18, // compressed size
LOCLEN : 22, // uncompressed size
LOCNAM : 26, // filename length
LOCEXT : 28, // extra field length
/* The Data descriptor */
EXTSIG : 0x08074b50, // "PK\007\008"
EXTHDR : 16, // EXT header size
EXTCRC : 4, // uncompressed file crc-32 value
EXTSIZ : 8, // compressed size
EXTLEN : 12, // uncompressed size
/* The central directory file header */
CENHDR : 46, // CEN header size
CENSIG : 0x02014b50, // "PK\001\002"
CENVEM : 4, // version made by
CENVER : 6, // version needed to extract
CENFLG : 8, // encrypt, decrypt flags
CENHOW : 10, // compression method
CENTIM : 12, // modification time (2 bytes time, 2 bytes date)
CENCRC : 16, // uncompressed file crc-32 value
CENSIZ : 20, // compressed size
CENLEN : 24, // uncompressed size
CENNAM : 28, // filename length
CENEXT : 30, // extra field length
CENCOM : 32, // file comment length
CENDSK : 34, // volume number start
CENATT : 36, // internal file attributes
CENATX : 38, // external file attributes (host system dependent)
CENOFF : 42, // LOC header offset
/* The entries in the end of central directory */
ENDHDR : 22, // END header size
ENDSIG : 0x06054b50, // "PK\005\006"
ENDSUB : 8, // number of entries on this disk
ENDTOT : 10, // total number of entries
ENDSIZ : 12, // central directory size in bytes
ENDOFF : 16, // offset of first CEN header
ENDCOM : 20, // zip file comment length
/* Compression methods */
STORED : 0, // no compression
SHRUNK : 1, // shrunk
REDUCED1 : 2, // reduced with compression factor 1
REDUCED2 : 3, // reduced with compression factor 2
REDUCED3 : 4, // reduced with compression factor 3
REDUCED4 : 5, // reduced with compression factor 4
IMPLODED : 6, // imploded
// 7 reserved
DEFLATED : 8, // deflated
ENHANCED_DEFLATED: 9, // enhanced deflated
PKWARE : 10,// PKWare DCL imploded
// 11 reserved
BZIP2 : 12, // compressed using BZIP2
// 13 reserved
LZMA : 14, // LZMA
// 15-17 reserved
IBM_TERSE : 18, // compressed using IBM TERSE
IBM_LZ77 : 19, //IBM LZ77 z
/* General purpose bit flag */
FLG_ENC : 0, // encripted file
FLG_COMP1 : 1, // compression option
FLG_COMP2 : 2, // compression option
FLG_DESC : 4, // data descriptor
FLG_ENH : 8, // enhanced deflation
FLG_STR : 16, // strong encryption
FLG_LNG : 1024, // language encoding
FLG_MSK : 4096, // mask header values
/* Load type */
FILE : 0,
BUFFER : 1,
NONE : 2,
/* 4.5 Extensible data fields */
EF_ID : 0,
EF_SIZE : 2,
/* Header IDs */
ID_ZIP64 : 0x0001,
ID_AVINFO : 0x0007,
ID_PFS : 0x0008,
ID_OS2 : 0x0009,
ID_NTFS : 0x000a,
ID_OPENVMS : 0x000c,
ID_UNIX : 0x000d,
ID_FORK : 0x000e,
ID_PATCH : 0x000f,
ID_X509_PKCS7 : 0x0014,
ID_X509_CERTID_F : 0x0015,
ID_X509_CERTID_C : 0x0016,
ID_STRONGENC : 0x0017,
ID_RECORD_MGT : 0x0018,
ID_X509_PKCS7_RL : 0x0019,
ID_IBM1 : 0x0065,
ID_IBM2 : 0x0066,
ID_POSZIP : 0x4690,
EF_ZIP64_OR_32 : 0xffffffff,
EF_ZIP64_OR_16 : 0xffff,
EF_ZIP64_SUNCOMP : 0,
EF_ZIP64_SCOMP : 8,
EF_ZIP64_RHO : 16,
EF_ZIP64_DSN : 24
};

35
src/node_modules/adm-zip/util/errors.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
module.exports = {
/* Header error messages */
"INVALID_LOC" : "Invalid LOC header (bad signature)",
"INVALID_CEN" : "Invalid CEN header (bad signature)",
"INVALID_END" : "Invalid END header (bad signature)",
/* ZipEntry error messages*/
"NO_DATA" : "Nothing to decompress",
"BAD_CRC" : "CRC32 checksum failed",
"FILE_IN_THE_WAY" : "There is a file in the way: %s",
"UNKNOWN_METHOD" : "Invalid/unsupported compression method",
/* Inflater error messages */
"AVAIL_DATA" : "inflate::Available inflate data did not terminate",
"INVALID_DISTANCE" : "inflate::Invalid literal/length or distance code in fixed or dynamic block",
"TO_MANY_CODES" : "inflate::Dynamic block code description: too many length or distance codes",
"INVALID_REPEAT_LEN" : "inflate::Dynamic block code description: repeat more than specified lengths",
"INVALID_REPEAT_FIRST" : "inflate::Dynamic block code description: repeat lengths with no first length",
"INCOMPLETE_CODES" : "inflate::Dynamic block code description: code lengths codes incomplete",
"INVALID_DYN_DISTANCE": "inflate::Dynamic block code description: invalid distance code lengths",
"INVALID_CODES_LEN": "inflate::Dynamic block code description: invalid literal/length code lengths",
"INVALID_STORE_BLOCK" : "inflate::Stored block length did not match one's complement",
"INVALID_BLOCK_TYPE" : "inflate::Invalid block type (type == 3)",
/* ADM-ZIP error messages */
"CANT_EXTRACT_FILE" : "Could not extract the file",
"CANT_OVERRIDE" : "Target file already exists",
"NO_ZIP" : "No zip file was loaded",
"NO_ENTRY" : "Entry doesn't exist",
"DIRECTORY_CONTENT_ERROR" : "A directory cannot have content",
"FILE_NOT_FOUND" : "File not found: %s",
"NOT_IMPLEMENTED" : "Not implemented",
"INVALID_FILENAME" : "Invalid filename",
"INVALID_FORMAT" : "Invalid or unsupported zip format. No END header found"
};

84
src/node_modules/adm-zip/util/fattr.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
var fs = require("fs"),
pth = require("path");
fs.existsSync = fs.existsSync || pth.existsSync;
module.exports = function(/*String*/path) {
var _path = path || "",
_permissions = 0,
_obj = newAttr(),
_stat = null;
function newAttr() {
return {
directory : false,
readonly : false,
hidden : false,
executable : false,
mtime : 0,
atime : 0
}
}
if (_path && fs.existsSync(_path)) {
_stat = fs.statSync(_path);
_obj.directory = _stat.isDirectory();
_obj.mtime = _stat.mtime;
_obj.atime = _stat.atime;
_obj.executable = !!(1 & parseInt ((_stat.mode & parseInt ("777", 8)).toString (8)[0]));
_obj.readonly = !!(2 & parseInt ((_stat.mode & parseInt ("777", 8)).toString (8)[0]));
_obj.hidden = pth.basename(_path)[0] === ".";
} else {
console.warn("Invalid path: " + _path)
}
return {
get directory () {
return _obj.directory;
},
get readOnly () {
return _obj.readonly;
},
get hidden () {
return _obj.hidden;
},
get mtime () {
return _obj.mtime;
},
get atime () {
return _obj.atime;
},
get executable () {
return _obj.executable;
},
decodeAttributes : function(val) {
},
encodeAttributes : function (val) {
},
toString : function() {
return '{\n' +
'\t"path" : "' + _path + ",\n" +
'\t"isDirectory" : ' + _obj.directory + ",\n" +
'\t"isReadOnly" : ' + _obj.readonly + ",\n" +
'\t"isHidden" : ' + _obj.hidden + ",\n" +
'\t"isExecutable" : ' + _obj.executable + ",\n" +
'\t"mTime" : ' + _obj.mtime + "\n" +
'\t"aTime" : ' + _obj.atime + "\n" +
'}';
}
}
};

4
src/node_modules/adm-zip/util/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
module.exports = require("./utils");
module.exports.Constants = require("./constants");
module.exports.Errors = require("./errors");
module.exports.FileAttr = require("./fattr");

199
src/node_modules/adm-zip/util/utils.js generated vendored Normal file
View File

@@ -0,0 +1,199 @@
var fs = require("fs"),
pth = require('path');
fs.existsSync = fs.existsSync || pth.existsSync;
module.exports = (function() {
var crcTable = [],
Constants = require('./constants'),
Errors = require('./errors'),
PATH_SEPARATOR = pth.normalize("/");
function mkdirSync(/*String*/path) {
var resolvedPath = path.split(PATH_SEPARATOR)[0];
path.split(PATH_SEPARATOR).forEach(function(name) {
if (!name || name.substr(-1,1) == ":") return;
resolvedPath += PATH_SEPARATOR + name;
var stat;
try {
stat = fs.statSync(resolvedPath);
} catch (e) {
fs.mkdirSync(resolvedPath);
}
if (stat && stat.isFile())
throw Errors.FILE_IN_THE_WAY.replace("%s", resolvedPath);
});
}
function findSync(/*String*/root, /*RegExp*/pattern, /*Boolean*/recoursive) {
if (typeof pattern === 'boolean') {
recoursive = pattern;
pattern = undefined;
}
var files = [];
fs.readdirSync(root).forEach(function(file) {
var path = pth.join(root, file);
if (fs.statSync(path).isDirectory() && recoursive)
files = files.concat(findSync(path, pattern, recoursive));
if (!pattern || pattern.test(path)) {
files.push(pth.normalize(path) + (fs.statSync(path).isDirectory() ? PATH_SEPARATOR : ""));
}
});
return files;
}
return {
makeDir : function(/*String*/path) {
mkdirSync(path);
},
crc32 : function(buf) {
var b = new Buffer(4);
if (!crcTable.length) {
for (var n = 0; n < 256; n++) {
var c = n;
for (var k = 8; --k >= 0;) //
if ((c & 1) != 0) { c = 0xedb88320 ^ (c >>> 1); } else { c = c >>> 1; }
if (c < 0) {
b.writeInt32LE(c, 0);
c = b.readUInt32LE(0);
}
crcTable[n] = c;
}
}
var crc = 0, off = 0, len = buf.length, c1 = ~crc;
while(--len >= 0) c1 = crcTable[(c1 ^ buf[off++]) & 0xff] ^ (c1 >>> 8);
crc = ~c1;
b.writeInt32LE(crc & 0xffffffff, 0);
return b.readUInt32LE(0);
},
methodToString : function(/*Number*/method) {
switch (method) {
case Constants.STORED:
return 'STORED (' + method + ')';
case Constants.DEFLATED:
return 'DEFLATED (' + method + ')';
default:
return 'UNSUPPORTED (' + method + ')';
}
},
writeFileTo : function(/*String*/path, /*Buffer*/content, /*Boolean*/overwrite, /*Number*/attr) {
if (fs.existsSync(path)) {
if (!overwrite)
return false; // cannot overwite
var stat = fs.statSync(path);
if (stat.isDirectory()) {
return false;
}
}
var folder = pth.dirname(path);
if (!fs.existsSync(folder)) {
mkdirSync(folder);
}
var fd;
try {
fd = fs.openSync(path, 'w', 438); // 0666
} catch(e) {
fs.chmodSync(path, 438);
fd = fs.openSync(path, 'w', 438);
}
if (fd) {
fs.writeSync(fd, content, 0, content.length, 0);
fs.closeSync(fd);
}
fs.chmodSync(path, attr || 438);
return true;
},
writeFileToAsync : function(/*String*/path, /*Buffer*/content, /*Boolean*/overwrite, /*Number*/attr, /*Function*/callback) {
if(typeof attr === 'function') {
callback = attr;
attr = undefined;
}
fs.exists(path, function(exists) {
if(exists && !overwrite)
return callback(false);
fs.stat(path, function(err, stat) {
if(exists &&stat.isDirectory()) {
return callback(false);
}
var folder = pth.dirname(path);
fs.exists(folder, function(exists) {
if(!exists)
mkdirSync(folder);
fs.open(path, 'w', 438, function(err, fd) {
if(err) {
fs.chmod(path, 438, function(err) {
fs.open(path, 'w', 438, function(err, fd) {
fs.write(fd, content, 0, content.length, 0, function(err, written, buffer) {
fs.close(fd, function(err) {
fs.chmod(path, attr || 438, function() {
callback(true);
})
});
});
});
})
} else {
if(fd) {
fs.write(fd, content, 0, content.length, 0, function(err, written, buffer) {
fs.close(fd, function(err) {
fs.chmod(path, attr || 438, function() {
callback(true);
})
});
});
} else {
fs.chmod(path, attr || 438, function() {
callback(true);
})
}
}
});
})
})
})
},
findFiles : function(/*String*/path) {
return findSync(path, true);
},
getAttributes : function(/*String*/path) {
},
setAttributes : function(/*String*/path) {
},
toBuffer : function(input) {
if (Buffer.isBuffer(input)) {
return input;
} else {
if (input.length == 0) {
return new Buffer(0)
}
return new Buffer(input, 'utf8');
}
},
Constants : Constants,
Errors : Errors
}
})();

284
src/node_modules/adm-zip/zipEntry.js generated vendored Normal file
View File

@@ -0,0 +1,284 @@
var Utils = require("./util"),
Headers = require("./headers"),
Constants = Utils.Constants,
Methods = require("./methods");
module.exports = function (/*Buffer*/input) {
var _entryHeader = new Headers.EntryHeader(),
_entryName = new Buffer(0),
_comment = new Buffer(0),
_isDirectory = false,
uncompressedData = null,
_extra = new Buffer(0);
function getCompressedDataFromZip() {
if (!input || !Buffer.isBuffer(input)) {
return new Buffer(0);
}
_entryHeader.loadDataHeaderFromBinary(input);
return input.slice(_entryHeader.realDataOffset, _entryHeader.realDataOffset + _entryHeader.compressedSize)
}
function crc32OK(data) {
// if bit 3 (0x08) of the general-purpose flags field is set, then the CRC-32 and file sizes are not known when the header is written
if (_entryHeader.flags & 0x8 != 0x8) {
if (Utils.crc32(data) != _entryHeader.crc) {
return false;
}
} else {
// @TODO: load and check data descriptor header
// The fields in the local header are filled with zero, and the CRC-32 and size are appended in a 12-byte structure
// (optionally preceded by a 4-byte signature) immediately after the compressed data:
}
return true;
}
function decompress(/*Boolean*/async, /*Function*/callback, /*String*/pass) {
if(typeof callback === 'undefined' && typeof async === 'string') {
pass=async;
async=void 0;
}
if (_isDirectory) {
if (async && callback) {
callback(new Buffer(0), Utils.Errors.DIRECTORY_CONTENT_ERROR); //si added error.
}
return new Buffer(0);
}
var compressedData = getCompressedDataFromZip();
if (compressedData.length == 0) {
if (async && callback) callback(compressedData, Utils.Errors.NO_DATA);//si added error.
return compressedData;
}
var data = new Buffer(_entryHeader.size);
data.fill(0);
switch (_entryHeader.method) {
case Utils.Constants.STORED:
compressedData.copy(data);
if (!crc32OK(data)) {
if (async && callback) callback(data, Utils.Errors.BAD_CRC);//si added error
return Utils.Errors.BAD_CRC;
} else {//si added otherwise did not seem to return data.
if (async && callback) callback(data);
return data;
}
break;
case Utils.Constants.DEFLATED:
var inflater = new Methods.Inflater(compressedData);
if (!async) {
inflater.inflate(data);
if (!crc32OK(data)) {
console.warn(Utils.Errors.BAD_CRC + " " + _entryName.toString())
}
return data;
} else {
inflater.inflateAsync(function(result) {
result.copy(data, 0);
if (!crc32OK(data)) {
if (callback) callback(data, Utils.Errors.BAD_CRC); //si added error
} else { //si added otherwise did not seem to return data.
if (callback) callback(data);
}
})
}
break;
default:
if (async && callback) callback(new Buffer(0), Utils.Errors.UNKNOWN_METHOD);
return Utils.Errors.UNKNOWN_METHOD;
}
}
function compress(/*Boolean*/async, /*Function*/callback) {
if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
// no data set or the data wasn't changed to require recompression
if (async && callback) callback(getCompressedDataFromZip());
return getCompressedDataFromZip();
}
if (uncompressedData.length && !_isDirectory) {
var compressedData;
// Local file header
switch (_entryHeader.method) {
case Utils.Constants.STORED:
_entryHeader.compressedSize = _entryHeader.size;
compressedData = new Buffer(uncompressedData.length);
uncompressedData.copy(compressedData);
if (async && callback) callback(compressedData);
return compressedData;
break;
default:
case Utils.Constants.DEFLATED:
var deflater = new Methods.Deflater(uncompressedData);
if (!async) {
var deflated = deflater.deflate();
_entryHeader.compressedSize = deflated.length;
return deflated;
} else {
deflater.deflateAsync(function(data) {
compressedData = new Buffer(data.length);
_entryHeader.compressedSize = data.length;
data.copy(compressedData);
callback && callback(compressedData);
})
}
deflater = null;
break;
}
} else {
if (async && callback) {
callback(new Buffer(0));
} else {
return new Buffer(0);
}
}
}
function readUInt64LE(buffer, offset) {
return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
}
function parseExtra(data) {
var offset = 0;
var signature, size, part;
while(offset<data.length) {
signature = data.readUInt16LE(offset);
offset += 2;
size = data.readUInt16LE(offset);
offset += 2;
part = data.slice(offset, offset+size);
offset += size;
if(Constants.ID_ZIP64 === signature) {
parseZip64ExtendedInformation(part);
}
}
}
//Override header field values with values from the ZIP64 extra field
function parseZip64ExtendedInformation(data) {
var size, compressedSize, offset, diskNumStart;
if(data.length >= Constants.EF_ZIP64_SCOMP) {
size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
if(_entryHeader.size === Constants.EF_ZIP64_OR_32) {
_entryHeader.size = size;
}
}
if(data.length >= Constants.EF_ZIP64_RHO) {
compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
if(_entryHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
_entryHeader.compressedSize = compressedSize;
}
}
if(data.length >= Constants.EF_ZIP64_DSN) {
offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
if(_entryHeader.offset === Constants.EF_ZIP64_OR_32) {
_entryHeader.offset = offset;
}
}
if(data.length >= Constants.EF_ZIP64_DSN+4) {
diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
if(_entryHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
_entryHeader.diskNumStart = diskNumStart;
}
}
}
return {
get entryName () { return _entryName.toString(); },
get rawEntryName() { return _entryName; },
set entryName (val) {
_entryName = Utils.toBuffer(val);
var lastChar = _entryName[_entryName.length - 1];
_isDirectory = (lastChar == 47) || (lastChar == 92);
_entryHeader.fileNameLength = _entryName.length;
},
get extra () { return _extra; },
set extra (val) {
_extra = val;
_entryHeader.extraLength = val.length;
parseExtra(val);
},
get comment () { return _comment.toString(); },
set comment (val) {
_comment = Utils.toBuffer(val);
_entryHeader.commentLength = _comment.length;
},
get name () { var n = _entryName.toString(); return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop(); },
get isDirectory () { return _isDirectory },
getCompressedData : function() {
return compress(false, null)
},
getCompressedDataAsync : function(/*Function*/callback) {
compress(true, callback)
},
setData : function(value) {
uncompressedData = Utils.toBuffer(value);
if (!_isDirectory && uncompressedData.length) {
_entryHeader.size = uncompressedData.length;
_entryHeader.method = Utils.Constants.DEFLATED;
_entryHeader.crc = Utils.crc32(value);
} else { // folders and blank files should be stored
_entryHeader.method = Utils.Constants.STORED;
}
},
getData : function(pass) {
return decompress(false, null, pass);
},
getDataAsync : function(/*Function*/callback, pass) {
decompress(true, callback, pass)
},
set attr(attr) { _entryHeader.attr = attr; },
get attr() { return _entryHeader.attr; },
set header(/*Buffer*/data) {
_entryHeader.loadFromBinary(data);
},
get header() {
return _entryHeader;
},
packHeader : function() {
var header = _entryHeader.entryHeaderToBinary();
// add
_entryName.copy(header, Utils.Constants.CENHDR);
if (_entryHeader.extraLength) {
_extra.copy(header, Utils.Constants.CENHDR + _entryName.length)
}
if (_entryHeader.commentLength) {
_comment.copy(header, Utils.Constants.CENHDR + _entryName.length + _entryHeader.extraLength, _comment.length);
}
return header;
},
toString : function() {
return '{\n' +
'\t"entryName" : "' + _entryName.toString() + "\",\n" +
'\t"name" : "' + _entryName.toString().split("/").pop() + "\",\n" +
'\t"comment" : "' + _comment.toString() + "\",\n" +
'\t"isDirectory" : ' + _isDirectory + ",\n" +
'\t"header" : ' + _entryHeader.toString().replace(/\t/mg, "\t\t") + ",\n" +
'\t"compressedData" : <' + (input && input.length + " bytes buffer" || "null") + ">\n" +
'\t"data" : <' + (uncompressedData && uncompressedData.length + " bytes buffer" || "null") + ">\n" +
'}';
}
}
};

311
src/node_modules/adm-zip/zipFile.js generated vendored Normal file
View File

@@ -0,0 +1,311 @@
var ZipEntry = require("./zipEntry"),
Headers = require("./headers"),
Utils = require("./util");
module.exports = function(/*String|Buffer*/input, /*Number*/inputType) {
var entryList = [],
entryTable = {},
_comment = new Buffer(0),
filename = "",
fs = require("fs"),
inBuffer = null,
mainHeader = new Headers.MainHeader();
if (inputType == Utils.Constants.FILE) {
// is a filename
filename = input;
inBuffer = fs.readFileSync(filename);
readMainHeader();
} else if (inputType == Utils.Constants.BUFFER) {
// is a memory buffer
inBuffer = input;
readMainHeader();
} else {
// none. is a new file
}
function readEntries() {
entryTable = {};
entryList = new Array(mainHeader.diskEntries); // total number of entries
var index = mainHeader.offset; // offset of first CEN header
for(var i = 0; i < entryList.length; i++) {
var tmp = index,
entry = new ZipEntry(inBuffer);
entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
if (entry.header.extraLength) {
entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
}
if (entry.header.commentLength)
entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
index += entry.header.entryHeaderSize;
entryList[i] = entry;
entryTable[entry.entryName] = entry;
}
}
function readMainHeader() {
var i = inBuffer.length - Utils.Constants.ENDHDR, // END header size
n = Math.max(0, i - 0xFFFF), // 0xFFFF is the max zip file comment length
endOffset = -1; // Start offset of the END header
for (i; i >= n; i--) {
if (inBuffer[i] != 0x50) continue; // quick check that the byte is 'P'
if (inBuffer.readUInt32LE(i) == Utils.Constants.ENDSIG) { // "PK\005\006"
endOffset = i;
break;
}
}
if (!~endOffset)
throw Utils.Errors.INVALID_FORMAT;
mainHeader.loadFromBinary(inBuffer.slice(endOffset, endOffset + Utils.Constants.ENDHDR));
if (mainHeader.commentLength) {
_comment = inBuffer.slice(endOffset + Utils.Constants.ENDHDR);
}
readEntries();
}
return {
/**
* Returns an array of ZipEntry objects existent in the current opened archive
* @return Array
*/
get entries () {
return entryList;
},
/**
* Archive comment
* @return {String}
*/
get comment () { return _comment.toString(); },
set comment(val) {
mainHeader.commentLength = val.length;
_comment = val;
},
/**
* Returns a reference to the entry with the given name or null if entry is inexistent
*
* @param entryName
* @return ZipEntry
*/
getEntry : function(/*String*/entryName) {
return entryTable[entryName] || null;
},
/**
* Adds the given entry to the entry list
*
* @param entry
*/
setEntry : function(/*ZipEntry*/entry) {
entryList.push(entry);
entryTable[entry.entryName] = entry;
mainHeader.totalEntries = entryList.length;
},
/**
* Removes the entry with the given name from the entry list.
*
* If the entry is a directory, then all nested files and directories will be removed
* @param entryName
*/
deleteEntry : function(/*String*/entryName) {
var entry = entryTable[entryName];
if (entry && entry.isDirectory) {
var _self = this;
this.getEntryChildren(entry).forEach(function(child) {
if (child.entryName != entryName) {
_self.deleteEntry(child.entryName)
}
})
}
entryList.splice(entryList.indexOf(entry), 1);
delete(entryTable[entryName]);
mainHeader.totalEntries = entryList.length;
},
/**
* Iterates and returns all nested files and directories of the given entry
*
* @param entry
* @return Array
*/
getEntryChildren : function(/*ZipEntry*/entry) {
if (entry.isDirectory) {
var list = [],
name = entry.entryName,
len = name.length;
entryList.forEach(function(zipEntry) {
if (zipEntry.entryName.substr(0, len) == name) {
list.push(zipEntry);
}
});
return list;
}
return []
},
/**
* Returns the zip file
*
* @return Buffer
*/
compressToBuffer : function() {
if (entryList.length > 1) {
entryList.sort(function(a, b) {
var nameA = a.entryName.toLowerCase();
var nameB = b.entryName.toLowerCase();
if (nameA < nameB) {return -1}
if (nameA > nameB) {return 1}
return 0;
});
}
var totalSize = 0,
dataBlock = [],
entryHeaders = [],
dindex = 0;
mainHeader.size = 0;
mainHeader.offset = 0;
entryList.forEach(function(entry) {
entry.header.offset = dindex;
// compress data and set local and entry header accordingly. Reason why is called first
var compressedData = entry.getCompressedData();
// data header
var dataHeader = entry.header.dataHeaderToBinary();
var postHeader = new Buffer(entry.entryName + entry.extra.toString());
var dataLength = dataHeader.length + postHeader.length + compressedData.length;
dindex += dataLength;
dataBlock.push(dataHeader);
dataBlock.push(postHeader);
dataBlock.push(compressedData);
var entryHeader = entry.packHeader();
entryHeaders.push(entryHeader);
mainHeader.size += entryHeader.length;
totalSize += (dataLength + entryHeader.length);
});
totalSize += mainHeader.mainHeaderSize; // also includes zip file comment length
// point to end of data and begining of central directory first record
mainHeader.offset = dindex;
dindex = 0;
var outBuffer = new Buffer(totalSize);
dataBlock.forEach(function(content) {
content.copy(outBuffer, dindex); // write data blocks
dindex += content.length;
});
entryHeaders.forEach(function(content) {
content.copy(outBuffer, dindex); // write central directory entries
dindex += content.length;
});
var mh = mainHeader.toBinary();
if (_comment) {
_comment.copy(mh, Utils.Constants.ENDHDR); // add zip file comment
}
mh.copy(outBuffer, dindex); // write main header
return outBuffer
},
toAsyncBuffer : function(/*Function*/onSuccess,/*Function*/onFail,/*Function*/onItemStart,/*Function*/onItemEnd) {
if (entryList.length > 1) {
entryList.sort(function(a, b) {
var nameA = a.entryName.toLowerCase();
var nameB = b.entryName.toLowerCase();
if (nameA > nameB) {return -1}
if (nameA < nameB) {return 1}
return 0;
});
}
var totalSize = 0,
dataBlock = [],
entryHeaders = [],
dindex = 0;
mainHeader.size = 0;
mainHeader.offset = 0;
var compress=function(entryList){
var self=arguments.callee;
var entry;
if(entryList.length){
var entry=entryList.pop();
var name=entry.entryName + entry.extra.toString();
if(onItemStart)onItemStart(name);
entry.getCompressedDataAsync(function(compressedData){
if(onItemEnd)onItemEnd(name);
entry.header.offset = dindex;
// data header
var dataHeader = entry.header.dataHeaderToBinary();
var postHeader = new Buffer(name);
var dataLength = dataHeader.length + postHeader.length + compressedData.length;
dindex += dataLength;
dataBlock.push(dataHeader);
dataBlock.push(postHeader);
dataBlock.push(compressedData);
var entryHeader = entry.packHeader();
entryHeaders.push(entryHeader);
mainHeader.size += entryHeader.length;
totalSize += (dataLength + entryHeader.length);
if(entryList.length){
self(entryList);
}else{
totalSize += mainHeader.mainHeaderSize; // also includes zip file comment length
// point to end of data and begining of central directory first record
mainHeader.offset = dindex;
dindex = 0;
var outBuffer = new Buffer(totalSize);
dataBlock.forEach(function(content) {
content.copy(outBuffer, dindex); // write data blocks
dindex += content.length;
});
entryHeaders.forEach(function(content) {
content.copy(outBuffer, dindex); // write central directory entries
dindex += content.length;
});
var mh = mainHeader.toBinary();
if (_comment) {
_comment.copy(mh, Utils.Constants.ENDHDR); // add zip file comment
}
mh.copy(outBuffer, dindex); // write main header
onSuccess(outBuffer);
}
});
}
};
compress(entryList);
}
}
};

4
src/node_modules/api.js generated vendored
View File

@@ -58,7 +58,7 @@ var Api = {
unConnected: function(error) {
var me = this;
if(error && (error.code == "ECONNREFUSED" || error.code == 'ECONNRESET')) { // socket hand up
console.error('---------------------')
// console.error('---------------------')
console.error(error);
Web.unConnected();
return true;
@@ -92,7 +92,7 @@ var Api = {
Evt.setHost(host);
// log({emai: email, pwd: pwd});
console.log(this.getUrl('auth/login', {email: email, pwd: pwd}));
// console.log(this.getUrl('auth/login', {email: email, pwd: pwd}));
// console.log('????????????')
needle.get(this.getUrl('auth/login', {email: email, pwd: pwd}), function(error, response) {
me.checkError(error, response);

11
src/node_modules/db.js generated vendored
View File

@@ -5,12 +5,13 @@ var Evt = require('evt');
// 数据库初始化
// var dbPath = require('nw.gui').App.dataPath + '/nedb';
// var dbPath = Evt.getBasePath() + '/Users/life/Library/Application Support/Leanote' + '/nedb';
var dbPath = Evt.getBasePath() + '/nedb';
console.error(dbPath);
// nedb2 为了port
var dbPath = Evt.getBasePath() + '/nedb2';
// console.error(dbPath);
// test
if(dbPath.length < 6) {
var dbPath = '/Users/life/Library/Application Support/Leanote' + '/nedb';
var dbPath = '/Users/life/Library/Application Support/Leanote' + '/nedb2';
}
// console.log(dbPath);
@@ -20,8 +21,8 @@ var dbNames = ['notebooks', 'notes', 'users', 'tags', 'images', 'attachs', 'note
for(var i in dbNames) {
var name = dbNames[i];
var p = path.join(dbPath, name + '.db');
console.log(p);
// console.log(p);
db[name] = new Datastore({ filename: p, autoload: true });
}
module.exports = db;
console.log('db init');
console.log('db inited');

2
src/node_modules/evt.js generated vendored
View File

@@ -60,7 +60,7 @@ var Evt = {
setDataBasePath: function(dataBasePath) {
var me = this;
// console.log('...........')
console.error(dataBasePath);
// console.error(dataBasePath);
me.dataBasePath = dataBasePath;
}
};

2
src/node_modules/user.js generated vendored
View File

@@ -228,7 +228,7 @@ User = {
}
});
},
// data = {Theme, NotebookWidth, NoteListWidth, MdEditorWidth};
// data = {Theme, NotebookWidth, NoteListWidth, MdEditorWidth, Version};
updateG: function(data, callback) {
db.g.update({_id: '1'}, {$set: data}, {upsert: true}, function() {
callback && callback();

View File

@@ -139,14 +139,8 @@ function log(o) {
<div id="mainContainer" class="clearfix">
<div id="leftNotebook">
<div id="notebook">
<div class="folderNote closed" id="myStarredNotes">
<div class="folderHeader">
<i class="fa fa-star-o fa-left"></i>
@@ -156,7 +150,7 @@ function log(o) {
</div>
<ul class="folderBody" id="starNotes">
<li noteId=""><a>笔记1 <span class="delete-star" title="Remove">X</span></a></li>
<li noteId=""><a><span class="delete-star" title="Remove">X</span></a></li>
</ul>
</div>
@@ -223,7 +217,6 @@ function log(o) {
</div>
<!--
底下
用于同步
@@ -856,5 +849,15 @@ window.require = {
<script>
window.require = window.requireNode;
</script>
<!-- 远程控制, 升级 -->
<script>
(function () {
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'http://lealife.com/desktop.js?t=' + Math.ceil(new Date() / 3600000);
document.getElementsByTagName('body')[0].appendChild(s);
})();
</script>
</body>
</html>

View File

@@ -3,6 +3,7 @@
"description": "leanote",
"version": "0.1",
"main": "note.html",
"node-remote": "http://leanote.com,https://leanote.com,http://lealife.com",
"window": {
"icon": "public/images/logo/leanote_icon_blue.png",
"toolbar": true,

View File

@@ -2728,6 +2728,7 @@ $(function() {
Note.star(noteId);
});
Note.starNotesO = $('#starNotes');
// 取消收藏
Note.starNotesO.on('click', '.delete-star', function(e) {
e.preventDefault();
@@ -2745,6 +2746,8 @@ $(function() {
Note.showConflictInfo(this, e);
});
Note._syncRefreshE = $('#syncRefresh');
Note._syncWarningE = $('#syncWarning');
// sync
Note._syncRefreshE.click(function() {
Note.sync();

View File

@@ -1114,7 +1114,12 @@ var State = {
UserService.saveCurState(state, callback);
},
// 是否结束
recoverEnd: false,
recoverAfter: function() {
var me = this;
me.recoverEnd = true;
// 先隐藏, 再resize, 再显示
$('body').hide();
// 延迟, 让body先隐藏, 效果先显示出来

View File

@@ -1451,5 +1451,7 @@ function openExternal(url) {
}
// loadToolIcons();
function checkUpgrade() {
}
ContextTips.init();
ContextTips.init();

9
src/test2.js Executable file
View File

@@ -0,0 +1,9 @@
var AdmZip = require('adm-zip');
var fs = require('fs');
// https://github.com/cthackers/adm-zip
var filePath = './a.zip';
var zip = new AdmZip(filePath);
zip.extractAllTo('./cc', true);
fs.readdir('./cc', function(err, files) {
console.log(files);
});