Represents a file in the filesystem.
More...
Represents a file in the filesystem.
- Warning
- Be sure to distinguish between get() and write() versus read() and put(), the former operates on the entire file, while the latter operates on a handle.
Definition at line 10 of file File.php.
◆ __construct()
FSTools_File::__construct |
( |
|
$name, |
|
|
|
$fs = false |
|
) |
| |
◆ __destruct()
FSTools_File::__destruct |
( |
| ) |
|
◆ chmod()
FSTools_File::chmod |
( |
|
$octal_code | ) |
|
Chmod a file.
- Note
- We ignore errors because of some weird owner trickery due to SVN duality
Definition at line 76 of file File.php.
78 return @$this->fs->chmod($this->name, $octal_code);
◆ close()
Closes file's handle.
Definition at line 90 of file File.php.
Referenced by __destruct(), and open().
92 if (!$this->handle)
return false;
93 $status = $this->fs->fclose($this->handle);
94 $this->handle =
false;
◆ delete()
Deletes the file.
Definition at line 54 of file File.php.
56 return $this->fs->unlink($this->name);
◆ eof()
Returns TRUE if the end of the file has been reached.
Definition at line 128 of file File.php.
130 if (!$this->handle)
return true;
131 return $this->fs->feof($this->handle);
◆ exists()
Returns true if file exists and is a file.
Definition at line 60 of file File.php.
62 return $this->fs->is_file($this->name);
◆ get()
Retrieves the contents of a file.
- Todo:
- Throw an exception if file doesn't exist
Definition at line 42 of file File.php.
44 return $this->fs->file_get_contents($this->name);
◆ getChar()
FSTools_File::getChar |
( |
| ) |
|
Retrieves a character from an open file.
Definition at line 107 of file File.php.
References open().
109 if (!$this->handle) $this->
open(
'r');
110 return $this->fs->fgetc($this->handle);
◆ getDirectory()
FSTools_File::getDirectory |
( |
| ) |
|
Returns directory of the file without trailing slash.
Definition at line 36 of file File.php.
36 {
return $this->fs->dirname($this->name);}
◆ getLine()
FSTools_File::getLine |
( |
|
$length = null | ) |
|
Retrieves a line from an open file, with optional max length $length.
Definition at line 99 of file File.php.
References open().
101 if (!$this->handle) $this->
open(
'r');
102 if ($length === null)
return $this->fs->fgets($this->handle);
103 else return $this->fs->fgets($this->handle, $length);
◆ getMTime()
FSTools_File::getMTime |
( |
| ) |
|
Returns last file modification time.
Definition at line 66 of file File.php.
68 return $this->fs->filemtime($this->name);
◆ getName()
FSTools_File::getName |
( |
| ) |
|
Returns the filename of the file.
Definition at line 33 of file File.php.
References $name.
◆ open()
FSTools_File::open |
( |
|
$mode | ) |
|
◆ put()
FSTools_File::put |
( |
|
$string | ) |
|
Writes to an open file.
Definition at line 121 of file File.php.
References open().
123 if (!$this->handle) $this->
open(
'a');
124 return $this->fs->fwrite($this->handle, $string);
◆ read()
FSTools_File::read |
( |
|
$length | ) |
|
Retrieves an $length bytes of data from an open data.
Definition at line 114 of file File.php.
References open().
116 if (!$this->handle) $this->
open(
'r');
117 return $this->fs->fread($this->handle, $length);
◆ write()
FSTools_File::write |
( |
|
$contents | ) |
|
Writes contents to a file, creates new file if necessary.
Definition at line 48 of file File.php.
References $contents.
50 return $this->fs->file_put_contents($this->name,
$contents);
◆ $fs
◆ $handle
FSTools_File::$handle = false |
|
protected |
Handle for the file.
Definition at line 17 of file File.php.
◆ $name
The documentation for this class was generated from the following file:
- libs/composer/vendor/ezyang/htmlpurifier/extras/FSTools/File.php