Return-Path: X-Original-To: apmail-flex-commits-archive@www.apache.org Delivered-To: apmail-flex-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 11F5E10FAA for ; Mon, 9 Dec 2013 23:30:05 +0000 (UTC) Received: (qmail 11023 invoked by uid 500); 9 Dec 2013 23:30:04 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 10941 invoked by uid 500); 9 Dec 2013 23:30:04 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 10567 invoked by uid 99); 9 Dec 2013 23:30:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Dec 2013 23:30:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C870D8B1BF2; Mon, 9 Dec 2013 23:30:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aharui@apache.org To: commits@flex.apache.org Date: Mon, 09 Dec 2013 23:30:14 -0000 Message-Id: <9efeeafeaaf743f8a1d4a63696d90afc@git.apache.org> In-Reply-To: <47777985614d4fc89033efb066538e37@git.apache.org> References: <47777985614d4fc89033efb066538e37@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/14] git commit: [flex-utilities] [refs/heads/develop] - get basic filesets to copy get basic filesets to copy Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/3a3f2326 Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/3a3f2326 Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/3a3f2326 Branch: refs/heads/develop Commit: 3a3f2326070cadf1cd6b6c14f1a916d74b0ce9df Parents: a4728f7 Author: Alex Harui Authored: Mon Dec 9 14:01:53 2013 -0800 Committer: Alex Harui Committed: Mon Dec 9 14:01:53 2013 -0800 ---------------------------------------------------------------------- ant_on_air/src/org/apache/flex/ant/tags/Copy.as | 36 +++++++-- .../src/org/apache/flex/ant/tags/FileSet.as | 1 + .../ant/tags/filesetClasses/DirectoryScanner.as | 77 ++++++++++---------- .../flex/ant/tags/filesetClasses/FileUtils.as | 8 +- .../ant/tags/filesetClasses/StringTokenizer.as | 18 +++-- .../tags/supportClasses/FileSetTaskHandler.as | 5 +- ant_on_air/tests/TestTarget.as | 7 ++ ant_on_air/tests/test.xml | 20 +++++ 8 files changed, 117 insertions(+), 55 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/Copy.as ---------------------------------------------------------------------- diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Copy.as b/ant_on_air/src/org/apache/flex/ant/tags/Copy.as index 4bdb0cc..3636ad0 100644 --- a/ant_on_air/src/org/apache/flex/ant/tags/Copy.as +++ b/ant_on_air/src/org/apache/flex/ant/tags/Copy.as @@ -18,6 +18,8 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.ant.tags { + import flash.filesystem.File; + import mx.core.IFlexModuleFactory; import org.apache.flex.ant.Ant; @@ -46,7 +48,7 @@ package org.apache.flex.ant.tags if (name == "file") fileName = value; else if (name == "toFile") - toFileName == value; + toFileName = value; else if (name == "toDir") toDirName = value; else if (name == "overwrite") @@ -57,17 +59,37 @@ package org.apache.flex.ant.tags override protected function actOnFile(dir:String, fileName:String):void { + var srcName:String; + if (dir) + srcName = dir + File.separator + fileName; + else + srcName = fileName; + var srcFile:File = File.applicationDirectory.resolvePath(srcName); + var destName:String; + if (toDirName) + destName = toDirName + File.separator + fileName; + else + destName = toFileName; + var destFile:File = File.applicationDirectory.resolvePath(destName); + + srcFile.copyTo(destFile, overwrite); } - /** - * Do the work. - * TaskHandlers lazily create their children so - * super.execute() should be called before - * doing any real work. - */ override public function execute():Boolean { + var retVal:Boolean = super.execute(); + if (numChildren > 0) + return retVal; + + var srcFile:File = File.applicationDirectory.resolvePath(fileName); + var destFile:File = File.applicationDirectory.resolvePath(toFileName);; + //var destDir:File = destFile.parent; + //var resolveName:String = destFile.nativePath.substr(destFile.nativePath.lastIndexOf(File.separator) + 1); + //destDir.resolvePath(resolveName); + + + srcFile.copyTo(destFile, overwrite); return true; } } http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as ---------------------------------------------------------------------- diff --git a/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as b/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as index 4a01395..c6fb109 100644 --- a/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as +++ b/ant_on_air/src/org/apache/flex/ant/tags/FileSet.as @@ -53,6 +53,7 @@ package org.apache.flex.ant.tags { if (_value) return _value; + ant.processChildren(xml, context, this); var ds:DirectoryScanner = new DirectoryScanner(); var n:int = numChildren; var includes:Vector. = new Vector.(); http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as ---------------------------------------------------------------------- diff --git a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as index e6f1927..379bb6c 100644 --- a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as +++ b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/DirectoryScanner.as @@ -526,11 +526,14 @@ package org.apache.flex.ant.tags.filesetClasses * @since Ant 1.6 */ public static function resetDefaultExcludes():Vector. { - defaultExcludes.length = 0; + var arr:Vector. = defaultExcludes; + if (!arr) + arr = new Vector.(); + arr.length = 0; for (var i:int = 0; i < DEFAULTEXCLUDES.length; i++) { - defaultExcludes.push(DEFAULTEXCLUDES[i]); + arr.push(DEFAULTEXCLUDES[i]); } - return defaultExcludes; + return arr; } /** @@ -819,6 +822,8 @@ package org.apache.flex.ant.tags.filesetClasses excludes = nullExcludes ? null : excludes; } catch (ex:IOException) { throw new BuildException(ex.message); + } catch (e:Error) { + throw new BuildException(e.message); } finally { basedir = savedBase; } @@ -843,14 +848,14 @@ package org.apache.flex.ant.tags.filesetClasses pattern; } } - for each (var entry:Dictionary in includeNonPatterns.entrySet()) { + for each (var entry:Object in includeNonPatterns) { for (var p:String in entry) { pattern = p; break; } if (!shouldSkipPattern(pattern)) { - newroots[entry.getValue()] = pattern; + newroots[entry[pattern]] = pattern; } } @@ -870,13 +875,9 @@ package org.apache.flex.ant.tags.filesetClasses } // only scan directories that can include matched files or // directories - for each (entry in newroots.entrySet()) { + for (entry in newroots) { var currentPath:TokenizedPath; - for (p in entry) - { - currentPath = p as TokenizedPath; - break; - } + currentPath = entry as TokenizedPath; var currentelement:String = currentPath.toString(); if (basedir == null && !FileUtils.isAbsolutePath(currentelement)) { @@ -895,7 +896,7 @@ package org.apache.flex.ant.tags.filesetClasses ? myCanonFile.nativePath : FILE_UTILS.removeLeadingPath(canonBase, myCanonFile); - if (!path == currentelement) { + if (path != currentelement) { myfile = currentPath.findFile(basedir, true); if (myfile != null && basedir != null) { currentelement = FILE_UTILS.removeLeadingPath( @@ -941,10 +942,7 @@ package org.apache.flex.ant.tags.filesetClasses } } else { var originalpattern:String; - for (var q:* in entry) - { - originalpattern = entry[q]; - } + originalpattern = newroots[entry] as String; var included:Boolean = isCaseSensitive() ? originalpattern == currentelement : originalpattern.toUpperCase() == currentelement.toUpperCase(); @@ -1089,21 +1087,21 @@ package org.apache.flex.ant.tags.filesetClasses if (dir == null) { throw new BuildException("dir must not be null."); } - var arr:Array = dir.getDirectoryListing(); + else if (!dir.exists) { + throw new BuildException(dir + DOES_NOT_EXIST_POSTFIX); + } else if (!dir.isDirectory) { + throw new BuildException(dir + " is not a directory."); + } + try { + var arr:Array = dir.getDirectoryListing(); + } catch (e:Error) { + throw new BuildException("IO error scanning directory '" + + dir.nativePath + "'"); + } var arr2:Array = []; for each (var f:File in arr) - arr2.push(f.nativePath); + arr2.push(f.name); var newfiles:Vector. = Vector.(arr2);; - if (newfiles == null) { - if (!dir.exists) { - throw new BuildException(dir + DOES_NOT_EXIST_POSTFIX); - } else if (!dir.isDirectory) { - throw new BuildException(dir + " is not a directory."); - } else { - throw new BuildException("IO error scanning directory '" - + dir.nativePath + "'"); - } - } _scandir(dir, path, fast, newfiles, new Vector.()); } @@ -1150,11 +1148,16 @@ package org.apache.flex.ant.tags.filesetClasses name = vpath + newfiles[i]; var newPath:TokenizedPath = new TokenizedPath("").initAsChild(path, newfiles[i]); file = new File(dir.nativePath + File.separator + newfiles[i]); - var arr:Array = file.getDirectoryListing(); + var arr:Array = null; var arr2:Array = []; - for each (var f:File in arr) - arr2.push(f.nativePath); - var children:Vector. = Vector.(arr2); + var children:Vector. = null; + if (file.isDirectory) + { + arr = file.getDirectoryListing(); + for each (var f:File in arr) + arr2.push(f.name); + children = Vector.(arr2); + } if (children == null || (children.length == 0 && !file.isDirectory)) { if (isIncludedPath(newPath)) { accountForIncludedFile(newPath, file); @@ -1272,8 +1275,8 @@ package org.apache.flex.ant.tags.filesetClasses ensureNonPatternSetsReady(); if (isCaseSensitive() - ? includeNonPatterns.containsKey(path.toString()) - : includeNonPatterns.containsKey(path.toString().toUpperCase())) { + ? includeNonPatterns.hasOwnProperty(path.toString()) + : includeNonPatterns.hasOwnProperty(path.toString().toUpperCase())) { return true; } for (var i:int = 0; i < includePatterns.length; i++) { @@ -1668,8 +1671,8 @@ package org.apache.flex.ant.tags.filesetClasses * @since Ant 1.6 */ private function clearCaches():void { - includeNonPatterns.clear(); - excludeNonPatterns.clear(); + includeNonPatterns = {}; + excludeNonPatterns = {}; includePatterns = null; excludePatterns = null; areNonPatternSetsReady = false; @@ -1698,7 +1701,7 @@ package org.apache.flex.ant.tags.filesetClasses * @since Ant 1.8.0 */ private function fillNonPatternSet(map:Object, patterns:Vector.):Vector. { - var al:Vector. = new Vector.(patterns.length); + var al:Vector. = new Vector.(); for (var i:int = 0; i < patterns.length; i++) { if (!SelectorUtils.hasWildcards(patterns[i])) { var s:String = isCaseSensitive() http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as ---------------------------------------------------------------------- diff --git a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as index d0409ca..146b972 100644 --- a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as +++ b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/FileUtils.as @@ -175,7 +175,7 @@ package org.apache.flex.ant.tags.filesetClasses var sep:String = File.separator; filename = filename.replace(/\//g, sep).replace(/\\/g, sep); var c:String = filename.charAt(0); - if (ON_DOS) + if (!ON_DOS) return (c == sep); if (c == sep) { @@ -258,7 +258,7 @@ package org.apache.flex.ant.tags.filesetClasses continue; } if (".." == thisToken) { - if (s.size() < 2) { + if (s.length < 2) { // Cannot resolve it, so skip it. return new File(path); } @@ -268,14 +268,14 @@ package org.apache.flex.ant.tags.filesetClasses } } var sb:String = ""; - var size:int = s.size(); + var size:int = s.length; for (var i:int = 0; i < size; i++) { if (i > 1) { // not before the filesystem root and not after it, since root // already contains one sb += File.separator; } - sb += s.elementAt(i); + sb += s[i]; } return new File(sb); } http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as ---------------------------------------------------------------------- diff --git a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as index fcd97ba..02ddff5 100644 --- a/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as +++ b/ant_on_air/src/org/apache/flex/ant/tags/filesetClasses/StringTokenizer.as @@ -27,29 +27,35 @@ package org.apache.flex.ant.tags.filesetClasses var c1:int = 0; var c2:int = 0; var n:int = s.length; - while (c1 < n) + while (c2 < n) { var c:String = s.charAt(c2); if (delims.indexOf(c) != -1) { - tokens.push(s.substring(c1, c2 - 1)); + tokens.push(s.substring(c1, c2)); c1 = c2; - while (c1 < n) + while (c2 < n) { c = s.charAt(c2); if (delims.indexOf(c) == -1) { if (returnDelims) - { - tokens.push(s.substring(c1, c2 - 1)) - } + tokens.push(s.substring(c1, c2)) c1 = c2; break; } + c2++; + } + if (returnDelims && c1 < c2) + { + tokens.push(s.substring(c1, c2)); + c1 = c2; } } c2++; } + if (c1 < n) + tokens.push(s.substring(c1)) } private var tokens:Vector.; http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as ---------------------------------------------------------------------- diff --git a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as index c399e52..c0320a8 100644 --- a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as +++ b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/FileSetTaskHandler.as @@ -18,6 +18,8 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.ant.tags.supportClasses { + import flash.filesystem.File; + import org.apache.flex.ant.tags.FileSet; /** @@ -47,9 +49,10 @@ package org.apache.flex.ant.tags.supportClasses var list:Vector. = fs.value as Vector.; if (list) { + var dir:File = new File(fs.dir); for each (var fileName:String in list) { - actOnFile(fs.dir, fileName); + actOnFile(dir.nativePath, fileName); } } } http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/tests/TestTarget.as ---------------------------------------------------------------------- diff --git a/ant_on_air/tests/TestTarget.as b/ant_on_air/tests/TestTarget.as index 1235d41..722986a 100644 --- a/ant_on_air/tests/TestTarget.as +++ b/ant_on_air/tests/TestTarget.as @@ -23,9 +23,16 @@ package import flash.events.Event; import flash.filesystem.File; import org.apache.flex.ant.Ant; + import org.apache.flex.ant.tags.Available; Available.init(null); import org.apache.flex.ant.tags.Condition; Condition.init(null); + import org.apache.flex.ant.tags.Copy; Copy.init(null); + import org.apache.flex.ant.tags.Delete; Delete.init(null); import org.apache.flex.ant.tags.Echo; Echo.init(null); + import org.apache.flex.ant.tags.FileSet; FileSet.init(null); + import org.apache.flex.ant.tags.FileSetExclude; FileSetExclude.init(null); + import org.apache.flex.ant.tags.FileSetInclude; FileSetInclude.init(null); import org.apache.flex.ant.tags.IsSet; IsSet.init(null); + import org.apache.flex.ant.tags.Mkdir; Mkdir.init(null); import org.apache.flex.ant.tags.OS; OS.init(null); import org.apache.flex.ant.tags.Project; Project.init(null); import org.apache.flex.ant.tags.Property; Property.init(null); http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/3a3f2326/ant_on_air/tests/test.xml ---------------------------------------------------------------------- diff --git a/ant_on_air/tests/test.xml b/ant_on_air/tests/test.xml index 5d55451..8114225 100644 --- a/ant_on_air/tests/test.xml +++ b/ant_on_air/tests/test.xml @@ -45,6 +45,26 @@ FLEX_HOME is ${FLEX_HOME}. DEBUG is ${DEBUG_FLAG}. The OS is ${theOS} + + + + copied ${copied.doesnt.exist}. Should say: got copied + + + + + + + + Ant.as ${ant.doesnt.exist}. Should NOT say: got copied + + Project.as ${project.doesnt.exist}. Should say: got copied + + + copied.xml ${copied.doesnt.exist.after.delete}. Should NOT say: didn't get deleted + + + Project.as ${project.doesnt.exist.after.delete}. Should NOT say: didn't get deleted