资源描述
uexZip对象封装了压缩 & 解压缩接口API.
使用示例
以下示例代码说明了如何使用uexZip对象的方法.
<!DOCTYPE html>
<html>
<head>
<title>AppCan API uexZip</title>
<meta charset='utf-8'>
</head>
<body>
<span>压缩</span><br/>
<input type='button' value='zip' onclick='zip()'/><br/>
<span>解压缩</span><br/>
<input type='button' value='unZip' onclick='unZip()'/><br/>
<span>加密压缩</span><br/>
<input type='button' value='zipPass' onclick='zipPass('zywx')'/><br/>
<span>加密解压缩</span><br/>
<input type='button' value='unZipPass' onclick='unZipPass('zywx')'/><br/>
</body>
<script>
var fileName = '';
window.uexOnload = function(type){
if(!type){
//uexZip.zip及uexZip.zipWithPassword压缩回调
uexZip.cbZip = function(opId,dataType,data){
if(dataType==2){
if(data==0){
alert('压缩成功!');
}else{
alert('压缩失败!');
}
}
}
//uexZip.zip及uexZip.zipWithPassword解压缩回调
uexZip.cbUnZip = function(opId,dataType,data){
if(dataType==2){
if(data==0){
alert('解压缩成功!');
}else{
alert('解压缩失败!');
}
}
}
}
}
/**
* uexZip支持文件、文件夹绝对路径压缩
*/
function zip(){
uexFileMgr.cbExplorer = function(opId,dataType,data){
if(dataType == 0){
fileName = data.substring(data.lastIndexOf('/')+1);
uexZip.zip(data,'wgt://data/zipDemo.zip');
}
}
uexFileMgr.explorer('');
}
/**
* 未加密zip解压缩
*/
function unZip(){
uexFileMgr.cbExplorer = function(opId, dataType, data){
if (dataType == 0) {
uexZip.unzip(data, 'wgt://data/');
}
}
uexFileMgr.explorer('');
}
/**
* 加密压缩
* @param {Object} pass 加密密码
*/
function zipPass(pass){
uexFileMgr.cbExplorer = function(opId,dataType,data){
if(dataType == 0){
fileName = data.substring(data.lastIndexOf('/')+1);
uexZip.zipWithPassword(data,'wgt://data/zipPass.zip',pass);
}
}
uexFileMgr.explorer('');
}
/**
* 解密解压缩
* @param {Object} pass 解密密码
*/
function unZipPass(pass){
uexFileMgr.cbExplorer = function(opId, dataType, data){
if (dataType == 0) {
uexZip.unzipWithPassword(data,'wgt://data/',pass);
}
}
uexFileMgr.explorer('');
}
</script>
</html>
Defined By
Methods
1,uexZip
zip (inSrcPath,inZippedPath)
压缩文件.
Parameters
inSrcPath
要压缩的文件或文件夹的路径。
inZippedPath
压缩后的zip文件。
2.uexZip
cbZip (opId,dataType,data)
uexZip.zip、uexZip.zipWithPassword的回调方法。
Parameters
opId
操作ID,在此函数中不起作用,可忽略。
dataType
返回数据的数据类型为uex.cInt(值为2)。
data
返回的int型的数据,0代表成功或1代表失败。
3,uexZip
zipWithPassword (inSrcPath,inZippedPath,inPassword)
加密压缩文件。
Parameters
inSrcPath
要压缩的文件或文件夹的路径。
inZippedPath
压缩后的zip文件。
inPassword
压缩的密码。
4,uexZip
unzip (inSrcPath,inZippedPath)
解压缩文件。
Parameters
inSrcPath
要解压的文件路径。
inZippedPath
解压后的文件路径。
5,uexZip
cbUnZip (opId,dataType,data)
uexZip.unzip、uexZip.unzipWithPassWord的回调方法。
Parameters
opId
操作ID,在此函数中不起作用,可忽略。
dataType
返回数据的数据类型为uex.cInt(值为2)。
data
返回的int型的数据,0代表成功或1代表失败。
6,uexZip
unzipWithPassWord (inSrcPath,inZippedPath,inPassword)
加密解压缩文件。
Parameters
inSrcPath
要解压的文件路径。
inZippedPath
解压后的文件路径。
inPassword
解压的密码。
展开阅读全文