flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [11/14] git commit: [flex-utilities] [refs/heads/develop] - add mkdir and delete tasks
Date Mon, 09 Dec 2013 23:30:13 GMT
add mkdir and delete tasks


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/a4728f76
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/a4728f76
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/a4728f76

Branch: refs/heads/develop
Commit: a4728f7629ddda6778a41e7c3cb655e61f759b44
Parents: 00bf3f9
Author: Alex Harui <aharui@apache.org>
Authored: Mon Dec 9 14:01:26 2013 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Dec 9 14:01:26 2013 -0800

----------------------------------------------------------------------
 ant_on_air/src/AntClasses.as                    |  2 +
 .../src/org/apache/flex/ant/tags/Delete.as      | 88 ++++++++++++++++++++
 .../src/org/apache/flex/ant/tags/Mkdir.as       | 60 +++++++++++++
 3 files changed, 150 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a4728f76/ant_on_air/src/AntClasses.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/AntClasses.as b/ant_on_air/src/AntClasses.as
index 3180f70..cc869ea 100644
--- a/ant_on_air/src/AntClasses.as
+++ b/ant_on_air/src/AntClasses.as
@@ -27,11 +27,13 @@ package
             import org.apache.flex.ant.tags.Available; Available;
             import org.apache.flex.ant.tags.Condition; Condition;
             import org.apache.flex.ant.tags.Copy; Copy;
+            import org.apache.flex.ant.tags.Delete; Delete;
             import org.apache.flex.ant.tags.Echo; Echo;
             import org.apache.flex.ant.tags.FileSet; FileSet;
             import org.apache.flex.ant.tags.FileSetExclude; FileSetExclude;
             import org.apache.flex.ant.tags.FileSetInclude; FileSetInclude;
             import org.apache.flex.ant.tags.IsSet; IsSet;
+            import org.apache.flex.ant.tags.Mkdir; Mkdir;
             import org.apache.flex.ant.tags.OS; OS;
             import org.apache.flex.ant.tags.Property; Property;
         }

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a4728f76/ant_on_air/src/org/apache/flex/ant/tags/Delete.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Delete.as b/ant_on_air/src/org/apache/flex/ant/tags/Delete.as
new file mode 100644
index 0000000..40f697a
--- /dev/null
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Delete.as
@@ -0,0 +1,88 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.ant.tags
+{
+    import flash.filesystem.File;
+    
+    import mx.core.IFlexModuleFactory;
+    
+    import org.apache.flex.ant.Ant;
+    import org.apache.flex.ant.tags.supportClasses.FileSetTaskHandler;
+    
+    [Mixin]
+    public class Delete extends FileSetTaskHandler
+    {
+        public static function init(mf:IFlexModuleFactory):void
+        {
+            Ant.antTagProcessors["delete"] = Delete;
+        }
+
+        public function Delete()
+        {
+            super();
+        }
+        
+        private var fileName:String;
+        private var dirName:String;
+        
+        override protected function processAttribute(name:String, value:String):void
+        {
+            if (name == "file")
+                fileName = value;
+            else if (name == "dir")
+                dirName = value;
+            else
+                super.processAttribute(name, value);
+        }
+
+        override protected function actOnFile(dir:String, fileName:String):void
+        {
+            var srcName:String;
+            if (dir)
+                srcName = dir + File.separator + fileName;
+            else
+                srcName = fileName;
+            var delFile:File = File.applicationDirectory.resolvePath(srcName);
+            if (delFile.isDirectory)
+                delFile.deleteDirectory(true);
+            else
+                delFile.deleteFile();
+        }
+        
+        override public function execute():Boolean
+        {
+            var retVal:Boolean = super.execute();
+            if (numChildren > 0)
+                return retVal;
+            
+            if (fileName)
+            {
+                var delFile:File = File.applicationDirectory.resolvePath(fileName);
+                delFile.deleteFile();
+            }
+            else if (dirName)
+            {
+                var delDir:File = File.applicationDirectory.resolvePath(dirName);
+                delDir.deleteDirectory(true);
+            }            
+            return true;
+        }
+        
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a4728f76/ant_on_air/src/org/apache/flex/ant/tags/Mkdir.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Mkdir.as b/ant_on_air/src/org/apache/flex/ant/tags/Mkdir.as
new file mode 100644
index 0000000..111b0aa
--- /dev/null
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Mkdir.as
@@ -0,0 +1,60 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.ant.tags
+{
+    import flash.filesystem.File;
+    
+    import mx.core.IFlexModuleFactory;
+    
+    import org.apache.flex.ant.Ant;
+    import org.apache.flex.ant.tags.supportClasses.TaskHandler;
+    
+    [Mixin]
+    public class Mkdir extends TaskHandler
+    {
+        public static function init(mf:IFlexModuleFactory):void
+        {
+            Ant.antTagProcessors["mkdir"] = Mkdir;
+        }
+
+        public function Mkdir()
+        {
+            super();
+        }
+        
+        private var _dir:String;
+        
+        override public function execute():Boolean
+        {
+            super.execute();
+            
+            var dir:File = new File(_dir);
+            dir.createDirectory();
+            
+            return true;
+        }
+        
+        override protected function processAttribute(name:String, value:String):void
+        {
+            if (name == "dir")
+                _dir = value;
+       }
+        
+    }
+}
\ No newline at end of file


Mime
View raw message