fix: 修复事件取消错误 修复file新建错误 修复解压错误
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
		@@ -16,11 +16,11 @@ exports.file = function () {
 | 
				
			|||||||
    if (!arguments[0]) {
 | 
					    if (!arguments[0]) {
 | 
				
			||||||
        log.w("文件名称不得为 undefined 或者 null !");
 | 
					        log.w("文件名称不得为 undefined 或者 null !");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (exports.canonical(arguments[0])) {
 | 
					 | 
				
			||||||
        return arguments[0];
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    switch (arguments.length) {
 | 
					    switch (arguments.length) {
 | 
				
			||||||
        case 1:
 | 
					        case 1:
 | 
				
			||||||
 | 
					            if (exports.canonical(arguments[0])) {
 | 
				
			||||||
 | 
					                return arguments[0];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            return new File(arguments[0]);
 | 
					            return new File(arguments[0]);
 | 
				
			||||||
        case 2:
 | 
					        case 2:
 | 
				
			||||||
            return new File(exports.file(arguments[0]), arguments[1]);
 | 
					            return new File(exports.file(arguments[0]), arguments[1]);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,21 +2,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/*global Java, base, module, exports, require, __FILE__*/
 | 
					/*global Java, base, module, exports, require, __FILE__*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var File = Java.type("java.io.File");
 | 
					 | 
				
			||||||
var ZipFile = Java.type("java.util.zip.ZipFile");
 | 
					var ZipFile = Java.type("java.util.zip.ZipFile");
 | 
				
			||||||
var fs = require('fs');
 | 
					var fs = require('fs');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * 获取文件真实名称
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @param name
 | 
					 | 
				
			||||||
 *            名称
 | 
					 | 
				
			||||||
 * @return string 文件名称
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
function getRealName(name) {
 | 
					 | 
				
			||||||
    return new File(name).name;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 解压文件
 | 
					 * 解压文件
 | 
				
			||||||
 * @param zipFile 压缩文件
 | 
					 * @param zipFile 压缩文件
 | 
				
			||||||
@@ -28,10 +16,11 @@ function unzip(zipFile, target) {
 | 
				
			|||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (target === undefined) {
 | 
					    if (target === undefined) {
 | 
				
			||||||
 | 
					        var fname = zipFile.name;
 | 
				
			||||||
        // noinspection JSUnresolvedVariable
 | 
					        // 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 zipObj = new ZipFile(zipFile);
 | 
				
			||||||
    var e = zipObj.entries();
 | 
					    var e = zipObj.entries();
 | 
				
			||||||
    while (e.hasMoreElements()) {
 | 
					    while (e.hasMoreElements()) {
 | 
				
			||||||
@@ -39,8 +28,8 @@ function unzip(zipFile, target) {
 | 
				
			|||||||
        if (entry.isDirectory()) {
 | 
					        if (entry.isDirectory()) {
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        var destinationFilePath = new File(target, getRealName(entry.name));
 | 
					        var destinationFilePath = fs.file(target, entry.name);
 | 
				
			||||||
        destinationFilePath.getParentFile().mkdirs();
 | 
					        destinationFilePath.parentFile.mkdirs();
 | 
				
			||||||
        fs.copy(zipObj.getInputStream(entry), destinationFilePath, true);
 | 
					        fs.copy(zipObj.getInputStream(entry), destinationFilePath, true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    zipObj.close();
 | 
					    zipObj.close();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -129,7 +129,7 @@ function unlisten(listener) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    listener.event.getMethod("getHandlerList").invoke(null).unregister(listener.listener);
 | 
					    listener.event.getMethod("getHandlerList").invoke(null).unregister(listener.listener);
 | 
				
			||||||
    // noinspection JSUnresolvedVariable
 | 
					    // noinspection JSUnresolvedVariable
 | 
				
			||||||
    log.d('注销事件 %s', eventCls.simpleName);
 | 
					    log.d('注销事件 %s', listener.event.simpleName);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var mapEvent = [];
 | 
					var mapEvent = [];
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user