4 * Represents a file in the filesystem
6 class XHTMLCompiler_File
9 /** Filename of file this object represents */
13 * Filename of file you wish to instantiate.
14 * @note This file need not exist
16 public function __construct($name) {
21 * Returns the filename of the file.
23 public function getName() {return $this->name
;}
26 * Returns directory of the file without trailing slash
28 public function getDirectory() {return dirname($this->name
);}
31 * Retrieves the contents of a file
32 * @todo Throw an exception if file doesn't exist
34 public function get() {
35 return file_get_contents($this->name
);
39 * Writes contents to a file, creates new file if necessary
40 * @param $contents String contents to write to file
42 public function write($contents) {
43 file_put_contents($this->name
, $contents);
49 public function delete() {
54 * Returns true if file exists and is a file.
56 public function exists() {
57 $php = XHTMLCompiler
::getPHPWrapper();
58 return $php->isFile($this->name
);
62 * Returns last file modification time
64 public function getMTime() {
65 return filemtime($this->name
);
68 /** Returns the last inode modifiation time */
69 public function getCTime() {
70 return filectime($this->name
);
75 * @note We ignore errors because of some weird owner trickery due
78 public function chmod($octal_code) {
79 @chmod
($this->name
, $octal_code);
85 public function touch() {