You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pi...@apache.org on 2017/10/25 15:47:19 UTC
git commit: [flex-utilities] [refs/heads/develop] - FLEX-35295 -
Fixed issue with unzipping Adobe Air on Windows by using powershell instead
cmd. (code provided by Josh Tynjala - Thanks!) This changes has to be
delivered along with fix for issue FLEX-35
Repository: flex-utilities
Updated Branches:
refs/heads/develop cffa3f0eb -> e7edfd84d
FLEX-35295 - Fixed issue with unzipping Adobe Air on Windows by using powershell instead cmd. (code provided by Josh Tynjala - Thanks!) This changes has to be delivered along with fix for issue FLEX-35364
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/e7edfd84
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/e7edfd84
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/e7edfd84
Branch: refs/heads/develop
Commit: e7edfd84da5f61a6e4ca8f2f4883648c1bc7d019
Parents: cffa3f0
Author: Piotr Zarzycki <pi...@gmail.com>
Authored: Wed Oct 25 17:47:15 2017 +0200
Committer: Piotr Zarzycki <pi...@gmail.com>
Committed: Wed Oct 25 17:47:15 2017 +0200
----------------------------------------------------------------------
.../src/org/apache/flex/ant/tags/Unzip.as | 76 ++++++++++++++++++--
1 file changed, 72 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e7edfd84/flex-installer/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as
----------------------------------------------------------------------
diff --git a/flex-installer/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as b/flex-installer/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as
index f4f385d..41b67f3 100644
--- a/flex-installer/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as
+++ b/flex-installer/ant_on_air/src/org/apache/flex/ant/tags/Unzip.as
@@ -18,11 +18,16 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.ant.tags
{
+ import flash.desktop.NativeProcess;
+ import flash.desktop.NativeProcessStartupInfo;
import flash.events.ErrorEvent;
import flash.events.Event;
+ import flash.events.NativeProcessExitEvent;
+ import flash.events.ProgressEvent;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
+ import flash.system.Capabilities;
import flash.utils.ByteArray;
import mx.core.IFlexModuleFactory;
@@ -67,6 +72,7 @@ package org.apache.flex.ant.tags
private var srcFile:File;
private var destFile:File;
private var patternSet:PatternSet;
+ private var _process:NativeProcess;
override public function execute(callbackMode:Boolean, context:Object):Boolean
{
@@ -129,11 +135,48 @@ package org.apache.flex.ant.tags
private function dounzip():void
{
- unzip(srcFile);
- dispatchEvent(new Event(Event.COMPLETE));
+ if (unzip(srcFile))
+ {
+ dispatchEvent(new Event(Event.COMPLETE));
+ }
}
-
- private function unzip(fileToUnzip:File):void {
+
+ private function winUnzip(source:File):void {
+ var executable:File = new File("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe");
+ var startupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
+ var arguments:Vector.<String> = new Vector.<String>();
+
+ var command:String = "& {";
+ command += "Param([string]$zipPath,[string]$outPath)$shell = New-Object -ComObject shell.application;$zip = $shell.NameSpace($zipPath);New-Item -path $outPath -type directory -force;$shell.NameSpace($outPath).CopyHere($zip.items(), 4 + 16);[Environment]::Exit(0);";
+ command += "}";
+ command += " ";
+ command += "\"";
+ command += source.nativePath;
+ command += "\"";
+ command += " ";
+ command += "\"";
+ command += destFile.nativePath;
+ command += "\"";
+ arguments.push("-Command");
+ arguments.push(command);
+
+ startupInfo.executable = executable;
+ startupInfo.arguments = arguments;
+
+ _process = new NativeProcess();
+ _process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onUnzipWinFileProgress);
+ _process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onUnzipWinError);
+ _process.addEventListener(NativeProcessExitEvent.EXIT, onUnzipWinComplete);
+ _process.start(startupInfo);
+ }
+
+ private function unzip(fileToUnzip:File):Boolean {
+ if (Capabilities.os.indexOf("Win") != -1)
+ {
+ winUnzip(fileToUnzip);
+ return false;
+ }
+
var zipFileBytes:ByteArray = new ByteArray();
var fs:FileStream = new FileStream();
var fzip:Zip = new Zip();
@@ -148,6 +191,8 @@ package org.apache.flex.ant.tags
// synchronous, so no progress events
fzip.loadBytes(zipFileBytes);
+
+ return true;
}
private function isDirectory(f:ZipFile):Boolean {
@@ -210,5 +255,28 @@ package org.apache.flex.ant.tags
ant.project.status = false;
}
}
+
+ private function onUnzipWinError(event:Event):void {
+ var output:String = _process.standardError.readUTFBytes(_process.standardError.bytesAvailable);
+ ant.output(output);
+ if (failonerror)
+ {
+ ant.project.failureMessage = output;
+ ant.project.status = false;
+ }
+ dispatchEvent(new Event(Event.COMPLETE));
+ }
+
+ private function onUnzipWinFileProgress(event:Event):void {
+ var output:String = _process.standardOutput.readUTFBytes(_process.standardOutput.bytesAvailable);
+ ant.output(output);
+ }
+
+ private function onUnzipWinComplete(event:NativeProcessExitEvent):void {
+ _process.closeInput();
+ _process.exit(true);
+ _process = null;
+ dispatchEvent(new Event(Event.COMPLETE));
+ }
}
}
\ No newline at end of file