* @copyright Copyright (c) 2008-9 TypeOneError Studios (http://www.typeoneerror.com) * @license MIT ~ http://www.opensource.org/licenses/mit-license.php * @version $Id$ * @link http://typeoneerror.com/asra * @category Asra * @package Utils */ /** * A few functions for working with caches * and the filesystem in general. * * @author Ben Borowski * @copyright Copyright (c) 2008-9 TypeOneError Studios (http://www.typeoneerror.com) * @license MIT ~ http://www.opensource.org/licenses/mit-license.php * @link http://typeoneerror.com/asra * @category Asra * @package Utils */ class Asra_Utils_Filesystem { /** * Safely delete a file * * @param string $file File name to delete * @return void */ public static function fileDelete($file) { if (!file_exists($file)) return false; return @unlink($file); } /** * Wrapper for reading file * * @return string|false Contents of file */ public static function fileRead($file) { return file_get_contents($file); } /** * Write some content to a file * * @param string $file Absolute path of file to write to * @param string $contents What to write to file * @return void */ public static function fileWrite($file, $contents = '') { $fp = fopen($file, 'w'); fwrite($fp, $contents); fclose($fp); } /** * Save some text to a file for testing * * @param string $output Output to write * @param string $file File to write to * @return void */ public static function trace($output, $file) { if (is_null($file)) $file = "trace.log"; $fp = fopen($file, "a"); fwrite($fp, $output . "\r"); fclose($fp); } /** * YAML header export * * @param string $filename Name of file to be outputted * @return void */ // @codeCoverageIgnoreStart public static function yaml($filename) { header('Content-type: application/x-yaml'); header('Content-Disposition: inline; filename=' . basename($filename)); } // @codeCoverageIgnoreEnd }