[Pkg-javascript-commits] [node-zipfile] 01/20: Imported Upstream version 0.4.0+ds1
Jérémy Lal
kapouer at alioth.debian.org
Fri Aug 30 13:36:31 UTC 2013
This is an automated email from the git hooks/post-receive script.
kapouer pushed a commit to branch master
in repository node-zipfile.
commit bfa3967892584d33c81b1cc18d01132bdf244c69
Author: Jérémy Lal <kapouer at melix.org>
Date: Fri Aug 30 15:14:09 2013 +0200
Imported Upstream version 0.4.0+ds1
---
.gitignore | 9 +
.npmignore | 1 -
Makefile | 45 ++---
binding.gyp | 67 +++++++
build.gyp | 82 ---------
configure | 2 +-
deps/common-libzip.gypi | 5 +
deps/notes.md | 4 +
lib/zipfile.js | 2 +-
package.json | 10 +-
src/_zipfile.cc | 28 ---
src/node_zipfile.cpp | 105 ++++++++++-
.../zipfile/node_zipfile.h => src/node_zipfile.hpp | 0
test/data/Archive/one.txt | 1 +
test/data/Archive/two.txt | 1 +
"test/data/Cl\303\251ment/Ol\303\241.txt" | 1 +
"test/data/Cl\303\251ment/Ol\303\241.zip" | Bin 0 -> 167 bytes
"test/data/Cl\303\251ment/foo.csv" | 2 +
"test/data/Cl\303\251ment/foo.csv.zip" | Bin 0 -> 536 bytes
test/data/points.csv.zip | Bin 0 -> 615 bytes
test/data/world_merc.zip | Bin 345387 -> 0 bytes
"test/data/\303\251\303\251\303\251/foo.csv" | 2 +
"test/data/\303\251\303\251\303\251/foo.csv.zip" | Bin 0 -> 536 bytes
"test/data/\344\275\240\345\245\275_points.csv" | 3 +
test/support/helper.js | 31 ----
test/unicode.test.js | 47 +++++
test/write.test.js | 42 ++---
vcbuild.bat | 17 +-
wscript | 185 --------------------
29 files changed, 283 insertions(+), 409 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fb0286e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+build
+.lock-wscript
+.DS_Store
+*.o
+*.a
+deps/libzip-0.10/
+lib/node_zipfile.node
+node_modules
+test/tmp/
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
deleted file mode 100644
index 7cdbba3..0000000
--- a/.npmignore
+++ /dev/null
@@ -1 +0,0 @@
-gmon.out
diff --git a/Makefile b/Makefile
index 0f7858d..a4841fc 100755
--- a/Makefile
+++ b/Makefile
@@ -1,29 +1,23 @@
-all: zipfile.node
+all: node_zipfile.node
-NPROCS:=1
-OS:=$(shell uname -s)
-
-ifeq ($(OS),Linux)
- NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
-endif
-ifeq ($(OS),Darwin)
- NPROCS:=$(shell sysctl -n hw.ncpu)
-endif
-
-install:
- node-waf -v build install
-
-zipfile.node:
- node-waf -v build
+node_zipfile.node:
+ `npm explore npm -g -- pwd`/bin/node-gyp-bin/node-gyp build
clean:
- node-waf -v clean distclean
-
-uninstall:
- node-waf -v uninstall
+ @rm -rf ./build
+ rm -f lib/node_zipfile.node
+ rm -f test/tmp/*
+ rm -rf ./deps/libzip-0.10/
+ rm -rf ./build
+ rm -rf ./out
+
+rebuild:
+ @make clean
+ @./configure
+ @make
test:
- @NODE_PATH=.:./lib:$NODE_PATH mocha -r zipfile -r assert
+ @PATH=./node_modules/mocha/bin:${PATH} && NODE_PATH=./lib:$NODE_PATH mocha -R spec
fix:
@fixjsstyle lib/*js bin/*js test/*js
@@ -37,11 +31,4 @@ lint:
lintc:
@cpplint.py --verbose=3 --filter=-legal,-build/namespaces,-whitespace/line_length src/*.* include/zipfile/*.*
-gyp:
- rm -rf ./projects/makefiles/
- python gyp/gyp build.gyp --depth=. -f make --generator-output=./projects/makefiles
- #./build.py
- make -j$(NPROCS) -C ./projects/makefiles/ V=1
- cp projects/makefiles/out/Default/_zipfile.node lib/_zipfile.node
-
-.PHONY: test lint fix lintc fixc gyp
\ No newline at end of file
+.PHONY: test lint fix lintc fixc
\ No newline at end of file
diff --git a/binding.gyp b/binding.gyp
new file mode 100644
index 0000000..008fdb8
--- /dev/null
+++ b/binding.gyp
@@ -0,0 +1,67 @@
+{
+ 'includes': [ 'deps/common-libzip.gypi' ],
+ 'variables': {
+ 'libzip%':'internal',
+ },
+ 'conditions': [
+ ['OS=="win"', {
+ 'variables': {
+ 'copy_command%': 'copy',
+ },
+ },{
+ 'variables': {
+ 'copy_command%': 'cp',
+ },
+ }]
+ ],
+ 'targets': [
+ {
+ 'target_name': 'node_zipfile',
+ 'conditions': [
+ ['libzip != "internal"', {
+ 'libraries': [
+ '-L<@(libzip)/lib',
+ '-lzip'
+ ],
+ 'include_dirs': [ '<@(libzip)/include' ]
+ },
+ {
+ 'dependencies': [
+ 'deps/libzip.gyp:libzip'
+ ]
+ }
+ ]
+ ],
+ 'sources': [
+ 'src/node_zipfile.cpp'
+ ],
+ },
+ {
+ 'target_name': 'action_after_build',
+ 'type': 'none',
+ 'dependencies': [ 'node_zipfile' ],
+ 'actions': [
+ {
+ 'action_name': 'move_node_module',
+ 'inputs': [
+ '<@(PRODUCT_DIR)/node_zipfile.node'
+ ],
+ 'outputs': [
+ 'lib/node_zipfile.node'
+ ],
+ 'action': ['<(copy_command)', '<@(PRODUCT_DIR)/node_zipfile.node', 'lib/node_zipfile.node']
+ }
+ ],
+ 'conditions': [
+ ['OS=="win"', {
+ 'copies': [
+ {
+ 'files': [ '<(PRODUCT_DIR)/libzip.dll' ],
+ 'destination': 'lib/'
+ }
+ ]
+ }]
+ ]
+ }
+ ]
+}
diff --git a/build.gyp b/build.gyp
deleted file mode 100644
index b4f611f..0000000
--- a/build.gyp
+++ /dev/null
@@ -1,82 +0,0 @@
-
-{
- 'variables': {
- 'node_module_sources': [
- "src/_zipfile.cc",
- "src/node_zipfile.cpp",
- ],
- 'node_root': '/opt/node-v6.1',
- 'node_root_win': 'c:\\node',
- 'deps_root_win': 'c:\\dev2'
- },
- 'targets': [
- {
- 'target_name': '_zipfile',
- 'product_name': '_zipfile',
- 'type': 'loadable_module',
- 'product_prefix': '',
- 'product_extension':'node',
- 'sources': [
- '<@(node_module_sources)',
- ],
- 'defines': [
- 'PLATFORM="<(OS)"',
- '_LARGEFILE_SOURCE',
- '_FILE_OFFSET_BITS=64',
- ],
- 'conditions': [
- [ 'OS=="mac"', {
- 'libraries': [
- '-lz',
- '-L../../deps/libzip-0.10/lib/.libs',
- '-lzip',
- '-undefined dynamic_lookup'
- ],
- 'include_dirs': [
- 'include/',
- 'deps/libzip-0.10/',
- 'deps/libzip-0.10/lib/',
- '<@(node_root)/include/node',
- '<@(node_root)/include',
- ],
- }],
- [ 'OS=="win"', {
- 'defines': [
- 'PLATFORM="win32"',
- '_WINDOWS',
- '__WINDOWS__', # ltdl
- 'BUILDING_NODE_EXTENSION'
- ],
- 'libraries': [
- 'node.lib',
- 'zip.lib',
- 'zlib.lib'
- ],
- 'include_dirs': [
- 'include',
- '<@(deps_root_win)\\node-zipfile\\deps\\libzip-0.10\\lib',
- '<@(deps_root_win)\\zlib',
- '<@(node_root_win)\\deps\\v8\\include',
- '<@(node_root_win)\\src',
- '<@(node_root_win)\\deps\\uv\\include',
- ],
- 'msvs_settings': {
- 'VCLinkerTool': {
- 'AdditionalOptions': [
- # https://github.com/mapnik/node-mapnik/issues/74
- '/FORCE:MULTIPLE'
- ],
- 'AdditionalLibraryDirectories': [
- '<@(deps_root_win)\\zlib',
- '<@(deps_root_win)\\node-zipfile\\deps\\libzip-0.10\\build_vc100\\lib',
- '<@(node_root_win)\\Release\\lib',
- '<@(node_root_win)\\Release',
- ],
- },
- },
- },
- ], # windows
- ] # condition
- }, # targets
- ],
-}
\ No newline at end of file
diff --git a/configure b/configure
index d153015..d0184d1 100755
--- a/configure
+++ b/configure
@@ -1,3 +1,3 @@
#!/bin/sh
-node-waf configure $@
\ No newline at end of file
+`npm explore npm -g -- pwd`/bin/node-gyp-bin/node-gyp configure $@
\ No newline at end of file
diff --git a/deps/common-libzip.gypi b/deps/common-libzip.gypi
new file mode 100644
index 0000000..4eaf7b1
--- /dev/null
+++ b/deps/common-libzip.gypi
@@ -0,0 +1,5 @@
+{
+ 'variables': {
+ 'libzip_version%':'0.11.1'
+ }
+}
\ No newline at end of file
diff --git a/deps/notes.md b/deps/notes.md
new file mode 100644
index 0000000..8255949
--- /dev/null
+++ b/deps/notes.md
@@ -0,0 +1,4 @@
+modified libzip-0.11.1-mod.tar.gz
+
+ - this patch applied: http://hg.nih.at/libzip/rev/6aeb5008ceeb
+ - lib/zipconf.h removed
\ No newline at end of file
diff --git a/lib/zipfile.js b/lib/zipfile.js
index c23a373..4885cc4 100644
--- a/lib/zipfile.js
+++ b/lib/zipfile.js
@@ -1,4 +1,4 @@
-var zipfile = require('./_zipfile');
+var zipfile = require('./node_zipfile.node');
exports = module.exports = zipfile;
diff --git a/package.json b/package.json
index ef2cf1d..cc69204 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name" : "zipfile",
- "version" : "0.3.1",
+ "version" : "0.4.0",
"main" : "./lib/index.js",
"description" : "C++ library for handling zipfiles in node",
"keywords" : ["zipfile", "uncompress", "unzip", "zlib"],
@@ -14,9 +14,10 @@
"author" : "Dane Springmeyer <dane at dbsgeo.com>",
"contributors" : [],
"licenses" : ["BSD"],
- "dependencies" : [],
+ "dependencies" : {},
"devDependencies": {
"mocha": "*",
+ "mkdirp": "~0.3.0",
"jshint" : "~0.5.x"
},
"bin" : {
@@ -26,9 +27,8 @@
"examples" : "examples",
"src": "src"
},
- "engines" : { "node": ">=0.6.0 <0.7" },
+ "engines" : { "node": ">= 0.6.13 && < 0.11.0" },
"scripts" : {
- "install" : "node-waf configure build",
- "test" : "make test"
+ "test" : "mocha -R spec"
}
}
diff --git a/src/_zipfile.cc b/src/_zipfile.cc
deleted file mode 100644
index ef683bc..0000000
--- a/src/_zipfile.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// v8
-#include <v8.h>
-
-// node
-#include <node.h>
-#include <node_version.h>
-
-// node-zipfile
-#include "zipfile/node_zipfile.h"
-
-using namespace node;
-using namespace v8;
-
-extern "C" {
- static void init(Handle<Object> target) {
- ZipFile::Initialize(target);
-
- // node-zipfile version
- target->Set(String::NewSymbol("version"), String::New("0.3.1"));
-
- // versions of deps
- Local<Object> versions = Object::New();
- versions->Set(String::NewSymbol("node"), String::New(NODE_VERSION+1));
- versions->Set(String::NewSymbol("v8"), String::New(V8::GetVersion()));
- target->Set(String::NewSymbol("versions"), versions);
- }
- NODE_MODULE(_zipfile, init);
-}
diff --git a/src/node_zipfile.cpp b/src/node_zipfile.cpp
index 62d0319..3a08709 100644
--- a/src/node_zipfile.cpp
+++ b/src/node_zipfile.cpp
@@ -1,15 +1,88 @@
-#include "zipfile/node_zipfile.h"
+#include "node_zipfile.hpp"
+#include <node_version.h>
#include <node_buffer.h>
+#ifdef _WINDOWS
+#include <Windows.h>
+#endif
+
// std
#include <sstream>
+#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define TOSTR(obj) (*String::Utf8Value((obj)->ToString()))
+#ifdef _WINDOWS
+std::string wstring2string(const std::wstring& s)
+{
+ DWORD size = WideCharToMultiByte(CP_UTF8,
+ 0,
+ s.c_str(),
+ -1,
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ if (size == 0) {
+ // This should never happen.
+ fprintf(stderr, "Could not convert arguments to utf8.");
+ }
+ char * buf_ptr = new char [size];
+ DWORD result = WideCharToMultiByte(CP_ACP,
+ 0,
+ s.c_str(),
+ -1,
+ buf_ptr,
+ size,
+ NULL,
+ NULL);
+ if (result == 0) {
+ // This should never happen.
+ fprintf(stderr, "Could not convert arguments to utf8.");
+ }
+ std::string r(buf_ptr);
+ delete buf_ptr;
+ return r;
+}
+
+std::wstring utf8ToWide( std::string const& s )
+{
+ int ws_len, r;
+ WCHAR* ws;
+ ws_len = MultiByteToWideChar(CP_UTF8,
+ 0,
+ s.c_str(),
+ -1,
+ NULL,
+ 0);
+ ws = new wchar_t [ws_len * sizeof(WCHAR)];
+ if (ws == NULL) {
+ // This should never happen.
+ fprintf(stderr, "Could not convert arguments from utf8.");
+ exit(1);
+ }
+ r = MultiByteToWideChar(CP_UTF8,
+ 0,
+ s.c_str(),
+ -1,
+ ws,
+ ws_len);
+ if (r != ws_len) {
+ // This should never happen.
+ fprintf(stderr, "Could not do anything useful.");
+ exit(1);
+ }
+ std::wstring rt(ws);
+ delete ws;
+ return rt;
+}
+
+#endif
+
Persistent<FunctionTemplate> ZipFile::constructor;
void ZipFile::Initialize(Handle<Object> target) {
@@ -45,7 +118,10 @@ Handle<Value> ZipFile::New(const Arguments& args) {
String::New("first argument must be a path to a zipfile")));
std::string input_file = TOSTR(args[0]);
- int err;
+#ifdef _WINDOWS
+ input_file = wstring2string(utf8ToWide(input_file));
+#endif
+ int err;
char errstr[1024];
struct zip *za;
if ((za=zip_open(input_file.c_str(), 0, &err)) == NULL) {
@@ -65,7 +141,8 @@ Handle<Value> ZipFile::New(const Arguments& args) {
for (i = 0; i < num; i++) {
struct zip_stat st;
zip_stat_index(za, i, 0, &st);
- zf->names_.push_back(st.name);
+ std::string name = st.name;
+ zf->names_.push_back(name);
}
zip_close(za);
zf->Wrap(args.This());
@@ -217,8 +294,7 @@ Handle<Value> ZipFile::readFile(const Arguments& args) {
closure->error = false;
closure->name = name;
closure->cb = Persistent<Function>::New(Handle<Function>::Cast(args[args.Length()-1]));
- uv_queue_work(uv_default_loop(), &closure->request, Work_ReadFile, Work_AfterReadFile);
- uv_ref(uv_default_loop());
+ uv_queue_work(uv_default_loop(), &closure->request, Work_ReadFile, (uv_after_work_cb)Work_AfterReadFile);
zf->Ref();
return Undefined();
}
@@ -292,7 +368,24 @@ void ZipFile::Work_AfterReadFile(uv_work_t* req) {
}
zip_close(closure->za);
closure->zf->Unref();
- uv_unref(uv_default_loop());
closure->cb.Dispose();
delete closure;
}
+
+
+extern "C" {
+ static void init(Handle<Object> target) {
+ ZipFile::Initialize(target);
+
+ // node-zipfile version
+ target->Set(String::NewSymbol("version"), String::New("0.3.1"));
+
+ // versions of deps
+ Local<Object> versions = Object::New();
+ versions->Set(String::NewSymbol("node"), String::New(NODE_VERSION+1));
+ versions->Set(String::NewSymbol("v8"), String::New(V8::GetVersion()));
+ target->Set(String::NewSymbol("versions"), versions);
+ }
+ NODE_MODULE(node_zipfile, init);
+}
+
diff --git a/include/zipfile/node_zipfile.h b/src/node_zipfile.hpp
similarity index 100%
rename from include/zipfile/node_zipfile.h
rename to src/node_zipfile.hpp
diff --git a/test/data/Archive/one.txt b/test/data/Archive/one.txt
new file mode 100644
index 0000000..5c1b149
--- /dev/null
+++ b/test/data/Archive/one.txt
@@ -0,0 +1 @@
+hola
diff --git a/test/data/Archive/two.txt b/test/data/Archive/two.txt
new file mode 100644
index 0000000..802cba7
--- /dev/null
+++ b/test/data/Archive/two.txt
@@ -0,0 +1 @@
+mundo
diff --git "a/test/data/Cl\303\251ment/Ol\303\241.txt" "b/test/data/Cl\303\251ment/Ol\303\241.txt"
new file mode 100644
index 0000000..341375b
--- /dev/null
+++ "b/test/data/Cl\303\251ment/Ol\303\241.txt"
@@ -0,0 +1 @@
+Olá
\ No newline at end of file
diff --git "a/test/data/Cl\303\251ment/Ol\303\241.zip" "b/test/data/Cl\303\251ment/Ol\303\241.zip"
new file mode 100644
index 0000000..fde953c
Binary files /dev/null and "b/test/data/Cl\303\251ment/Ol\303\241.zip" differ
diff --git "a/test/data/Cl\303\251ment/foo.csv" "b/test/data/Cl\303\251ment/foo.csv"
new file mode 100644
index 0000000..d436ff3
--- /dev/null
+++ "b/test/data/Cl\303\251ment/foo.csv"
@@ -0,0 +1,2 @@
+x,y
+0,0
\ No newline at end of file
diff --git "a/test/data/Cl\303\251ment/foo.csv.zip" "b/test/data/Cl\303\251ment/foo.csv.zip"
new file mode 100644
index 0000000..f5a433c
Binary files /dev/null and "b/test/data/Cl\303\251ment/foo.csv.zip" differ
diff --git a/test/data/points.csv.zip b/test/data/points.csv.zip
new file mode 100644
index 0000000..cf8be1d
Binary files /dev/null and b/test/data/points.csv.zip differ
diff --git a/test/data/world_merc.zip b/test/data/world_merc.zip
deleted file mode 100644
index 1d32ccc..0000000
Binary files a/test/data/world_merc.zip and /dev/null differ
diff --git "a/test/data/\303\251\303\251\303\251/foo.csv" "b/test/data/\303\251\303\251\303\251/foo.csv"
new file mode 100644
index 0000000..d436ff3
--- /dev/null
+++ "b/test/data/\303\251\303\251\303\251/foo.csv"
@@ -0,0 +1,2 @@
+x,y
+0,0
\ No newline at end of file
diff --git "a/test/data/\303\251\303\251\303\251/foo.csv.zip" "b/test/data/\303\251\303\251\303\251/foo.csv.zip"
new file mode 100644
index 0000000..f5a433c
Binary files /dev/null and "b/test/data/\303\251\303\251\303\251/foo.csv.zip" differ
diff --git "a/test/data/\344\275\240\345\245\275_points.csv" "b/test/data/\344\275\240\345\245\275_points.csv"
new file mode 100644
index 0000000..a36badb
--- /dev/null
+++ "b/test/data/\344\275\240\345\245\275_points.csv"
@@ -0,0 +1,3 @@
+x,y,bigint
+0,0,2147483648
+0,0,9223372036854775807
diff --git a/test/support/helper.js b/test/support/helper.js
deleted file mode 100644
index 3eb563c..0000000
--- a/test/support/helper.js
+++ /dev/null
@@ -1,31 +0,0 @@
-var path = require('path');
-var fs = require('fs');
-
-exports.mkdirP = function(p, mode, callback) {
- var that = this;
- // if relative
- if (p.charAt(0) != '/') {
- // if >= node 0.3.0 use path.resolve()
- p = path.join(__dirname, p);
- }
- var ps = path.normalize(p).split('/');
- path.exists(p, function(exists) {
- if (exists) {
- callback(null);
- } else {
- that.mkdirP(ps.slice(0, -1).join('/'), mode, function(err) {
- if (err && !err.code.match(/^EEXIST/)) {
- callback(err);
- } else {
- fs.mkdir(p, mode, function(err) {
- if (err && !err.code.match(/^EEXIST/)) {
- callback(err);
- } else {
- callback(null);
- }
- });
- }
- });
- };
- });
-};
diff --git a/test/unicode.test.js b/test/unicode.test.js
new file mode 100644
index 0000000..3331558
--- /dev/null
+++ b/test/unicode.test.js
@@ -0,0 +1,47 @@
+var zipfile = require('zipfile');
+var assert = require('assert');
+var fs = require('fs');
+var existsSync = require('fs').existsSync || require('path').existsSync;
+
+describe('Handling unicode paths, filenames, and data', function(){
+
+ it('open zip with folder with unicode', function(){
+ var zippath = './test/data/Clément/foo.csv.zip';
+ assert.ok(existsSync(zippath));
+ var zf = new zipfile.ZipFile(zippath);
+ assert.equal(zf.count, 3);
+ var buffer = zf.readFileSync(zf.names[0]);
+ assert.equal(buffer.toString('utf8'),fs.readFileSync(zippath.replace('.zip','')).toString('utf8').replace(/\r/g,''));
+ });
+
+ it('open zip with folder and file with unicode', function(){
+ var zippath = './test/data/Clément/Olá.zip';
+ assert.ok(existsSync(zippath));
+ var zf = new zipfile.ZipFile(zippath);
+ assert.equal(zf.count, 1);
+ });
+
+ it('open zip with unicode paths and unicode filenames in archive', function(){
+ var zippath = './test/data/Clément/Olá.zip';
+ assert.ok(existsSync(zippath));
+ var zf = new zipfile.ZipFile(zippath);
+ assert.equal(zf.count, 1);
+ assert.deepEqual(zf.names, ['Olá.txt']);
+ zf.names.forEach(function(name) {
+ var buffer = zf.readFileSync(name);
+ assert.equal(buffer.toString('utf8'),'Olá\n');
+ });
+ });
+
+ it('open zip with ansi path but unicode filename in archive', function(){
+ // created with OS X 10.7 with right-click, then "compress"
+ var zippath = './test/data/points.csv.zip';
+ assert.ok(existsSync(zippath));
+ var zf = new zipfile.ZipFile(zippath);
+ assert.equal(zf.count, 3);
+ assert.deepEqual(zf.names, ["你好_points.csv","__MACOSX/","__MACOSX/._你好_points.csv"]);
+ var buffer = zf.readFileSync(zf.names[0]);
+ assert.equal(buffer.toString('utf8'),fs.readFileSync('./test/data/你好_points.csv').toString('utf8').replace(/\r/g,''));
+ });
+
+});
diff --git a/test/write.test.js b/test/write.test.js
index 9f929ac..0cab917 100644
--- a/test/write.test.js
+++ b/test/write.test.js
@@ -1,19 +1,18 @@
var zipfile = require('zipfile');
var assert = require('assert');
-var support = require('./support/helper');
var path = require('path');
var fs = require('fs');
var constants = require('constants');
+var mkdirp = require('mkdirp');
+var existsSync = require('fs').existsSync || require('path').existsSync;
describe('Async Writes', function(){
var zf = new zipfile.ZipFile('./test/data/world_merc.zip');
- var wrote = 0;
-
- it('async write', function(done){
- zf.names.forEach(function(name) {
- var dest = path.join('/tmp/async', name);
- support.mkdirP(path.dirname(dest), 0755 , function(err) {
+ zf.names.forEach(function(name) {
+ it('async write '+ name, function(done){
+ var dest = path.join(__dirname,'tmp', name);
+ mkdirp(path.dirname(dest), 0755 , function(err) {
if (err) throw err;
if (path.extname(name)) {
zf.readFile(name, function(err, buffer) {
@@ -25,9 +24,8 @@ describe('Async Writes', function(){
// written is number of bytes written
assert.ok(written > 0);
fs.close(fd, function(err) {
- wrote++;
- if (wrote >= 4) done();
if (err) throw err;
+ done();
});
});
});
@@ -37,37 +35,25 @@ describe('Async Writes', function(){
});
});
- after(function(){
- assert.equal(wrote, 4);
- });
-
});
describe('Sync Writes', function(){
-
var zf = new zipfile.ZipFile('./test/data/world_merc.zip');
- var wrote = 0;
-
- it('sync write', function(){
- zf.names.forEach(function(name) {
- var uncompressed = path.join('/tmp/sync', name);
- var dirname = path.dirname(uncompressed);
- support.mkdirP(dirname, 0755 , function(err) {
+ zf.names.forEach(function(name) {
+ var uncompressed = path.join('/tmp/sync', name);
+ var dirname = path.dirname(uncompressed);
+ mkdirp(dirname, 0755 , function(err) {
+ it('sync write '+ name, function(done){
if (err && !err.message.match(/^EEXIST/)) throw err;
if (path.extname(name)) {
var buffer = zf.readFileSync(name);
var fd = fs.openSync(uncompressed, 'w');
fs.writeSync(fd, buffer, 0, buffer.length, null);
fs.closeSync(fd);
- assert.ok(path.existsSync(uncompressed));
- ++wrote;
+ assert.ok(existsSync(uncompressed));
+ done();
}
});
});
});
-
- after(function(){
- assert.equal(wrote, 4);
- });
-
});
\ No newline at end of file
diff --git a/vcbuild.bat b/vcbuild.bat
index 1eb8cd3..8723ca6 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -1,14 +1,7 @@
-del build.sln
-rd /q /s Default
-del lib\\_zipfile.node
-python gyp/gyp build.gyp --depth=. -f msvs -G msvs_version=2010
-msbuild build.sln
-copy Default\\_zipfile.node lib\\_zipfile.node
+rd /q /s build
+del lib\\node_zipfile.node
+npm install
+copy build\Release\libzip.dll lib
rem test!
set NODE_PATH=lib
-rem have to put zip.lib on PATH
-set PATH=%PATH%;c:\\dev2\node-zipfile\\lib
-copy deps\\libzip-0.10\\build_vc100\\lib\\zip.dll lib\\zip.dll
-rem node node_modules\expresso\bin\expresso
-mocha
-rem node -e "console.log(require('zipfile'))"
+npm test
diff --git a/wscript b/wscript
deleted file mode 100644
index 0e272c3..0000000
--- a/wscript
+++ /dev/null
@@ -1,185 +0,0 @@
-import os
-from glob import glob
-from os import unlink, symlink, popen, uname, environ
-from os.path import exists
-from shutil import copy2 as copy, rmtree
-from subprocess import call
-
-# http://www.freehackers.org/~tnagy/wafbook/index.html
-
-# node-wafadmin
-import Options
-import Utils
-
-TARGET = '_zipfile'
-TARGET_FILE = '%s.node' % TARGET
-built = 'build/Release/%s' % TARGET_FILE
-dest = 'lib/%s' % TARGET_FILE
-settings = 'lib/settings.js'
-BUNDLED_LIBZIP_VERSION = '0.10'
-BUNDLED_LIBZIP = 'libzip-%s' % BUNDLED_LIBZIP_VERSION
-BUNDLED_LIBZIP_TAR = 'libzip-%s.tar.bz2' % BUNDLED_LIBZIP_VERSION
-
-def set_options(opt):
- opt.tool_options("compiler_cxx")
- opt.tool_options('misc')
- opt.add_option( '--libzip'
- , action='store'
- , default=None
- , help='Directory prefix containing libzip "lib" and "include" files'
- , dest='shared_libzip_dir'
- )
-
- opt.add_option( '--shared-libzip'
- , action='store_true'
- , default=False
- , help='Build dynamically against external install of libzip (default False - build uses internal copy)'
- , dest='shared_libzip'
- )
-
-def configure_libzip():
- if not Options.options.shared_libzip:
- Utils.pprint('GREEN','configuring internal libzip dep')
- os.chdir('deps')
- if not os.path.exists(BUNDLED_LIBZIP):
- os.system('tar xvf %s' % BUNDLED_LIBZIP_TAR)
- os.chdir(BUNDLED_LIBZIP)
- cxxflags = ''
- if os.environ.has_key('CFLAGS'):
- cxxflags += os.environ['CFLAGS']
- cxxflags += ' '
- if os.environ.has_key('CXXFLAGS'):
- cxxflags += os.environ['CXXFLAGS']
- # LINKFLAGS appear to be picked up automatically...
- os.system("CFLAGS='%s -fPIC -O3 -DNDEBUG -Wall' ./configure --disable-dependency-tracking --enable-static --disable-shared" % cxxflags)
- os.chdir('../../')
-
-def configure(conf):
- conf.check_tool("compiler_cxx")
- conf.check_tool("node_addon")
- configure_libzip()
-
- libzip_includes = []
- libzip_libpath = []
- auto_configured = False
- o = Options.options
- libzip_dir = o.shared_libzip_dir
- shared_libzip = o.shared_libzip
-
- if libzip_dir:
- norm_path = os.path.realpath(libzip_dir)
- if norm_path.endswith('lib') or norm_path.endswith('include'):
- norm_path = os.path.dirname(norm_path)
-
- libzip_includes = [os.path.join('%s' % norm_path,'include'),
- os.path.join('%s' % norm_path,'lib/libzip/include')
- ]
- libzip_libpath = [os.path.join('%s' % norm_path,'lib')]
-
- elif shared_libzip:
- pkg_config = conf.find_program('pkg-config', var='PKG_CONFIG', mandatory=False)
- if pkg_config:
- cmd = '%s libzip' % pkg_config
- if int(call(cmd.split(' '))) == 0:
- Utils.pprint('GREEN','Sweet, found libzip via pkg-config')
- libzip_includes.extend(popen("pkg-config --cflags libzip").readline().strip().split(' '))
- libzip_libpath.extend(popen("pkg-config --libs libzip").readline().strip().split(' '))
- auto_configured = True
-
- if not auto_configured:
- # reasonable defaults for searching
- libzip_includes = ['/usr/local/include',
- '/usr/local/lib/libzip/include',
- '/usr/include',
- '/usr/lib/libzip/include',
- ]
- libzip_libpath = ['/usr/local/lib','/usr/lib']
-
- elif not shared_libzip:
- auto_configured = True
- libzip_includes = ['-I../deps/%s/lib' % BUNDLED_LIBZIP]
- libzip_libpath = ['../deps/%s/lib/.libs/libzip.a' % BUNDLED_LIBZIP]
-
- if not auto_configured:
- if not conf.check_cxx(lib='zip', header_name='zip.h',
- uselib_store='ZIP',
- includes=libzip_includes,
- libpath=libzip_libpath):
- conf.fatal("\n\n Cannot find libzip, required for node-zipfile,\n please install from:\n 'http://nih.at/libzip/'\n (see README.md for more info)\n")
- else:
- Utils.pprint('GREEN', 'Sweet, found viable libzip dependency')
-
- # strip paths that don't exist, turn into proper flags
- new_inc = []
- for i in libzip_includes:
- if os.path.exists(i):
- new_inc.append('-I%s' % i)
- libzip_includes = new_inc
-
- new_inc = []
- for i in libzip_libpath:
- if os.path.exists(i):
- new_inc.append('-L%s' % i)
- libzip_libpath = new_inc
-
- linkflags = []
- if os.environ.has_key('LINKFLAGS'):
- linkflags = os.environ['LINKFLAGS'].split(' ')
- linkflags.extend(libzip_libpath)
- if shared_libzip:
- if '-lzip' not in linkflags:
- linkflags.append('-lzip')
- elif Options.platform == 'darwin':
- linkflags.append('-Wl,-search_paths_first')
-
- if '-lz' not in linkflags:
- linkflags.append('-lz')
-
- conf.env.append_value("LINKFLAGS", linkflags)
-
- cxxflags = libzip_includes
-
- conf.env.append_value("CXXFLAGS", cxxflags)
-
- #ldflags = []
- #conf.env.append_value("LDFLAGS", ldflags)
-
-def build_libzip():
- if not Options.options.shared_libzip:
- os.chdir('deps/%s' % BUNDLED_LIBZIP)
- os.system('make')
- os.chdir('../../')
-
-def build(bld):
- obj = bld.new_task_gen("cxx", "shlib", "node_addon", install_path=None)
- build_libzip()
- obj.cxxflags = ["-I../include/","-DNDEBUG", "-O3", "-g", "-Wall", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE"]
- obj.target = TARGET
- obj.source = "src/_zipfile.cc"
- obj.source += " src/node_zipfile.cpp"
- obj.uselib = "ZIPFILE"
- start_dir = bld.path.find_dir('lib')
- # http://www.freehackers.org/~tnagy/wafbook/index.html#_installing_files
- bld.install_files('${LIBPATH_NODE}/node/zipfile', start_dir.ant_glob('*'), cwd=start_dir, relative_trick=True)
- # install command line programs
- bin_dir = bld.path.find_dir('./bin')
- bld.install_files('${PREFIX_NODE}/bin', bin_dir.ant_glob('*'), cwd=bin_dir, relative_trick=True, chmod=0755)
-
-def clean_libzip():
- if not Options.options.shared_libzip:
- if os.path.exists('deps/%s' % BUNDLED_LIBZIP):
- rmtree('deps/%s' % BUNDLED_LIBZIP)
-
-def clean(bld):
- pass # to avoid "Nothing to clean (project not configured)" error
-
-def shutdown():
- if Options.commands['clean']:
- if exists(TARGET): unlink(TARGET)
- clean_libzip()
- if Options.commands['clean']:
- if exists(dest):
- unlink(dest)
- else:
- if exists(built):
- copy(built,dest)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/node-zipfile.git
More information about the Pkg-javascript-commits
mailing list