You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2014/07/25 04:29:42 UTC
[3/7] git commit: [flex-utilities] [refs/heads/develop] - Add new tag
to check free disk space
Add new tag to check free disk space
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/025f4616
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/025f4616
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/025f4616
Branch: refs/heads/develop
Commit: 025f4616b6735e841153e8fdb82c7eafe453510e
Parents: 3a2ca9e
Author: Justin Mclean <jm...@apache.org>
Authored: Fri Jul 25 12:26:56 2014 +1000
Committer: Justin Mclean <jm...@apache.org>
Committed: Fri Jul 25 12:26:56 2014 +1000
----------------------------------------------------------------------
.../org/apache/flex/ant/tags/HasFreeSpace.as | 68 ++++++++++++++++++++
1 file changed, 68 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/025f4616/ant_on_air/src/org/apache/flex/ant/tags/HasFreeSpace.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/HasFreeSpace.as b/ant_on_air/src/org/apache/flex/ant/tags/HasFreeSpace.as
new file mode 100644
index 0000000..45ee06d
--- /dev/null
+++ b/ant_on_air/src/org/apache/flex/ant/tags/HasFreeSpace.as
@@ -0,0 +1,68 @@
+/*
+ * 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.IValueTagHandler;
+ import org.apache.flex.ant.tags.supportClasses.TagHandler;
+
+ [Mixin]
+ public class HasFreeSpace extends TagHandler implements IValueTagHandler
+ {
+ public static function init(mf:IFlexModuleFactory):void
+ {
+ Ant.antTagProcessors["hasfreespace"] = HasFreeSpace;
+ }
+
+ public function HasFreeSpace()
+ {
+ super();
+ }
+
+ private function get partition():String
+ {
+ return getAttributeValue("@partition");
+ }
+
+ private function get needed():String
+ {
+ return getAttributeValue("@needed");
+ }
+
+ public function getValue(context:Object):Object
+ {
+ var file:File = new File(partition);
+ var space:Number = file.spaceAvailable;
+ var postfix:String = needed.substr(-1,1);
+ var amount:Number = Number(needed.substr(0, needed.length-1));
+
+ for each (var modifier:String in ["K","M","G","T","P"]) {
+ amount *= 1024;
+ if (postfix == modifier) {
+ break;
+ }
+ }
+
+ return (space >= amount);
+ }
+
+ }
+}
\ No newline at end of file