2 Star 2 Fork 0

Sail / hzip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

hzip 定向压缩或者解压缩ZIP文件

var fs = require("fs");
var zlib = require("zlib");
var Hzip = require("../hzip");
var hzip = new Hzip(fs.readFileSync("./test.zip"),"GBK");
//替换或增加文件
hzip.updateEntry("testDir/中文test.txt",fs.readFileSync("./test.txt"),function(err,buffer){
	if(err) {
		console.log(err);
		return;
	}
	if(fs.existsSync("./test2.zip") === true) fs.unlinkSync("./test2.zip");
	fs.writeFileSync("./test2.zip",buffer);
	
	//解压文件
	var entry = hzip.getEntry("testDir/test.txt");
	zlib.inflateRaw(entry.cfile,function(err,buf){
		console.log(buf.toString());
	});
});

由于Excel2007以上的版本其实都是zip文件,里面就是xml文档 那么,你懂的,它可以用来导入导出Excel2007或者以上的版本 实际项目中已经在用了

安装: npm install hzip

hzip.updateEntry(fileName,fileBuf,callback) 第一个参数是文件在压缩包里面的路径,如果这个路径fileName不存在,则会自动创建这个文件夹 如果这个路径上已经有这个文件了,则会覆盖这个文件, 第二个参数是fileBuf,需要压缩的文件的buffer对象,如果为undefined或者null值,则会删除这个文件fileName

捐赠鼓励支持此项目:

捐赠鼓励支持此项目

The MIT License (MIT) Copyright (c) 2015 Sail 黄智勇 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
NodeJS
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
NodeJS
1
https://gitee.com/ccteams/hzip.git
git@gitee.com:ccteams/hzip.git
ccteams
hzip
hzip
master

搜索帮助