Class File
File handling class.
The File class can be use for creating, reading and manipulating the contents of a file. If you need to change a configuration file, this may be the class for you. However, configuration files come in many different forms, so this might not have what you need. Feel free to do your own file parsing.
Located in /api/File.class.php (line 215)
Engine | --File
| Class | Description |
|---|---|
| ConfigurationFile | Configuration file handling class. |
Inherited Variables
Inherited from Engine
Engine::$errors
Appends data to a file.
The method does not automatically add a newline - that is up to you!
- string $data: line (or lines) to append to the file
Appends a line (or lines) to a file at a particular location in the file.
- string $data: line(s) to insert into file
- string $after: regular expression defining the file location
Prepends a line (or lines) to a file at a particular location in the file.
- string $data: line(s) to insert into file
- string $before: regular expression defining the file location
Changes file mode.
- string $mode: mode of the file
Changes file owner and/or group.
Leave the owner or group blank if you do not want change one or the other.
- string $owner: file owner
- string $group: file group
File constructor.
- boolean $superuser: superuser access required to read the file
- boolean $temporary: create a temporary file
- string $filename: filename target file
- Engine::__construct()
- Engine constructor.
- ConfigurationFile::__construct() : Configuration file constructor.
Copies the file to new location.
- string $destination: destination location
Creates a file on the system.
- string $owner: file owner
- string $group: file group
- string $mode: mode of the file
Deletes the file.
Removes lines from a file that match the regular expression.
- string $search: regular expression used to match removed lines
Writes array data to a file.
The method does not automatically add a newline - that is up to you! This method will return an error if the file does not exist.
- array $contents: an array containing output lines
Checks the existence of the file.
Returns the contents of a file.
Set maxbytes to -1 to disable file size limit.
- int $maxbytes: maximum number of bytes
Returns the contents of a file in an array.
Set maxbytes to -1 to disable file size limit.
- int $maxbytes: maximum number of bytes
Returns the filename.
Returns the MD5 hash of the file.
Returns the octal permissions of the current file.
Returns the contents of a file that match the given regular expression.
Set maxbytes to -1 to disable file size limit.
- string $regex: search string
- int $maxbytes: maximum number of bytes
Returns the file size.
Checks to see if specified file is a directory.
Checks to see if specified file is a symbolic link.
Returns the last modified date of the file.
Searches the file with the given regular expression and returns the first match.
- string $search: regular expression
Returns a value for a given unique regular expression.
This method is handy for simple configuration files with key/value pairs. The method will return a FileNoMatchException error if no match was made.
- string $key: search string
Similar to LookupValue, except you can specify a subsection of the target file.
The start and end are regular expressions. This can be handy in Apache-style configuration files (e.g. configuring a particular Virtual Host).
- string $key: search string
- string $start: regular expression specifying the start line
- string $end: regular expression specifying the end line
Moves the file to new location.
- string $destination: destination location
Prepends lines with a string (usually a comment character).
Any line matching the search string will be changed.
- string $prepend: prepend string
- string $search: regular expression used to match removed lines
Replaces the contents of the given tempfile to this file.
This is basically a "mv" with the following behavior:
- This file (the one passed to the constructor) must exist.
- The tempfile is deleted if successful.
- The tempfile will take on the same file permissions and ownership as the target file.
- string $tempfile: temp file
Replaces a line (defined by a regular expression) with a replacement.
- string $search: search string
- string $replacement: replacement line (or lines)
- integer $maxreplaced: maximum number of matches to make
Replaces lines in a section of a file for Apache-style configuration files.
Specify the (non-unique) start and end tags along with a search value that uniquely defines the section.
- string $start: regular expression specifying the start line
- string $end: regular expression specifying the end line
- string $search: regular expression for the search string
- string $replacement: replacement line
Replaces all matching lines defined by a regular expression.
- string $search: search expression
- string $replacement: replacement expression
Replaces a line defined by a regular expression.
- string $search: search string
- string $replacement: replacement line (or lines)
Replaces a line defined by a regular expression.
This version differs from ReplaceOneLine in that it uses preg_replace to do the substitution. Thus you can use parts of a pattern match in the replacement (ie: $1, $2, etc).
- string $search: search expression
- string $replacement: replacement expression
Inherited Methods
Inherited From Engine
Engine::__construct()
Engine::AddValidationError()
Engine::CheckValidationErrors()
Engine::CopyValidationErrors()
Engine::GetValidationErrors()
Engine::Log()
Engine::__destruct()
CMD_CAT
= '/bin/cat'
(line 246)
CMD_CHMOD
= '/bin/chmod'
(line 251)
CMD_CHOWN
= '/bin/chown'
(line 250)
CMD_COPY
= '/bin/cp'
(line 248)
CMD_FILE
= '/usr/bin/file'
(line 254)
CMD_HEAD
= '/usr/bin/head'
(line 255)
CMD_LS
= '/bin/ls'
(line 252)
CMD_MD5
= '/usr/bin/md5sum'
(line 253)
CMD_MOVE
= '/bin/mv'
(line 247)
CMD_REPLACE
= '/usr/sbin/app-rename'
(line 256)
CMD_RM
= '/bin/rm'
(line 245)
CMD_TOUCH
= '/bin/touch'
(line 249)
Inherited Constants
Inherited from Engine
Engine::COMMAND_API
Documentation generated on Fri, 28 Aug 2009 20:32:04 -0400 by phpDocumentor 1.3.2

