blob: 6982f4378b218e4888c3dab2c98e1d5674555f80 [file] [log] [blame]
////////////////////////////////////////////////////////////////////////////////
//
// 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 flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import mx.core.IFlexModuleFactory;
import mx.resources.ResourceManager;
import org.apache.flex.ant.Ant;
import org.apache.flex.ant.tags.supportClasses.TaskHandler;
[ResourceBundle("ant")]
[Mixin]
public class Touch extends TaskHandler
{
public static function init(mf:IFlexModuleFactory):void
{
Ant.antTagProcessors["touch"] = Touch;
}
public function Touch()
{
}
override public function execute(callbackMode:Boolean, context:Object):Boolean
{
super.execute(callbackMode, context);
try {
var f:File = new File(fileName);
}
catch (e:Error)
{
ant.output(fileName);
ant.output(e.message);
if (failonerror)
{
ant.project.failureMessage = e.message;
ant.project.status = false;
}
return true;
}
var s:String = ResourceManager.getInstance().getString('ant', 'TOUCH');
s = s.replace("%1", f.nativePath);
ant.output(ant.formatOutput("touch", s));
var fs:FileStream = new FileStream();
fs.open(f, FileMode.APPEND);
fs.close();
return true;
}
private function get fileName():String
{
return getAttributeValue("@file");
}
}
}