Tangra_File __construct(
string
$file_name, [string
$open_mode = NULL]
)
|
|
Constructs the object
If parameter $open_mode is passed - constructor will open the file.
- 'r' - Open for reading only; place the file pointer at the beginning of the file.
- 'r+' - Open for reading and writing; place the file pointer at the beginning of the file.
- 'w' - Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
- 'w+' - Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
- 'a' - Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
- 'a+' - Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
- 'x' - Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.
- 'x+' - Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.
Parameters:
|
string |
$file_name: |
|
|
string |
$open_mode: |
|
Closes the file
API Tags:
Information Tags:
| Throws: | TE_File_Close_Failed |
Returns file name
API Tags:
Reads line from the file and returns it
Wrapper around PHP's fgets() Please note that newline sequences are included in return value so you may need to call trim() to get rif of them
If file pointer is at the end - returns NULL. If some error occures - throws TE_File_Get_Line_Failed
API Tags:
Information Tags:
| Throws: | TE_File_Has_Not_Been_Open, TE_File_Get_Line_Failed |
void open(
unknown_type
$mode
)
|
|
Opens the file.
See __construct for desctription of $mode parameter
Parameters:
API Tags:
Information Tags:
| Throws: | TE_File_Open_Failed |
boolean read(
integer
$length
)
|
|
Reads up to $length bytes from the file pointer. Reading stops when up to $length bytes have been read, EOF (end of file) is reached, or (for network streams) when a packet becomes available, whichever comes first.
Wrapper around PHP's fread() function Reads up to $length bytes from the file pointer. Reading stops when up to $length bytes have been read, EOF (end of file) is reached, or (for network streams) when a packet becomes available, whichever comes first.
Parameters:
API Tags:
Reads the whole file and returns it's content
API Tags:
void write(
string
$str, [integer
$length = NULL]
)
|
|
Writes the contents of $str to the file
Wrapper around PHP's fwrite() function Writes the contents of $str to the file. If the length argument is given, writing will stop after length bytes have been written or the end of string is reached, whichever comes first.
Parameters:
|
string |
$str: |
|
|
integer |
$length: |
|
API Tags:
Information Tags:
| Throws: | TE_File_Write_Failed, TE_File_Has_Not_Been_Open |