fix: 修复事件取消错误 修复file新建错误 修复解压错误

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2017-10-10 01:25:56 +08:00
parent 0cdf1cf106
commit 59b2824413
3 changed files with 9 additions and 20 deletions

View File

@ -16,11 +16,11 @@ exports.file = function () {
if (!arguments[0]) {
log.w("文件名称不得为 undefined 或者 null !");
}
if (exports.canonical(arguments[0])) {
return arguments[0];
}
switch (arguments.length) {
case 1:
if (exports.canonical(arguments[0])) {
return arguments[0];
}
return new File(arguments[0]);
case 2:
return new File(exports.file(arguments[0]), arguments[1]);

View File

@ -2,21 +2,9 @@
/*global Java, base, module, exports, require, __FILE__*/
var File = Java.type("java.io.File");
var ZipFile = Java.type("java.util.zip.ZipFile");
var fs = require('fs');
/**
* 获取文件真实名称
*
* @param name
* 名称
* @return string 文件名称
*/
function getRealName(name) {
return new File(name).name;
}
/**
* 解压文件
* @param zipFile 压缩文件
@ -28,10 +16,11 @@ function unzip(zipFile, target) {
return;
}
if (target === undefined) {
var fname = zipFile.name;
// noinspection JSUnresolvedVariable
target = new File(zipFile.parentFile.canonicalPath, zipFile.name.split(".")[0]);
target = fs.file(zipFile.parentFile.canonicalPath, fname.substring(0, fname.length() - 4));
}
log.d("解压文件 %s => %s", zipFile.canonicalPath, target);
log.d("解压文件 %s 到目录 %s", zipFile.canonicalPath, target);
var zipObj = new ZipFile(zipFile);
var e = zipObj.entries();
while (e.hasMoreElements()) {
@ -39,8 +28,8 @@ function unzip(zipFile, target) {
if (entry.isDirectory()) {
continue;
}
var destinationFilePath = new File(target, getRealName(entry.name));
destinationFilePath.getParentFile().mkdirs();
var destinationFilePath = fs.file(target, entry.name);
destinationFilePath.parentFile.mkdirs();
fs.copy(zipObj.getInputStream(entry), destinationFilePath, true);
}
zipObj.close();

View File

@ -129,7 +129,7 @@ function unlisten(listener) {
}
listener.event.getMethod("getHandlerList").invoke(null).unregister(listener.listener);
// noinspection JSUnresolvedVariable
log.d('注销事件 %s', eventCls.simpleName);
log.d('注销事件 %s', listener.event.simpleName);
}
var mapEvent = [];