Description:
With this object you can create, read, and write files on the server
Methods:
$data = $f.read($count); - Reads data from a file. $f.write($data); - Writes data to a file. close() - Closes the file File($filename) - Constructor open([$mode]) - Opens the file.
Example:
// create or overwrite crowley's .plan file
// note that you probably can't do this unless crowley has
//really silly file permissions
$f = new File("/home/crowley/.plan");
$f.open("w+");
$f.write("This is an empty .plan file.");
$f.close();
// now print crowley's .plan file
$f = new File("/home/crowley/.plan");
print ($f.read());
| Member name: $data = $f.read($count); | Class File |
Description:
If no argument is given, the read method will return the entire file. If the argument is provided, read() will return the next $count bytes from the opened file.
Usage:
print($f.read());
| $count | - | optional number of bytes to read |
| Member name: $f.write($data); | Class File |
Description:
Writes the string $data to the file. If the file is not opened before a call to write is made, the file is opened in mode "a+" which will create the file if needed and position the cursor at the end of the file. If the file was opened in a non-write mode, the behaviour of this method is undefined and should not be counted upon to be consistant (certainly not across server operating systems)
Usage:
$f.write($stuff)
| $data | - | String to be written to the file |
| Member name: close() | Class File |
Description:
Closes the file
Usage:
$f.close()
| Member name: File($filename) | Class File |
Description:
Creates a new file object. No initialization is done at this point.
Usage:
$f = new File($filename);
| $f | - | Reference to the new File object |
| $filename | - | Name on the sever for the file this object will work with |
| Member name: open([$mode]) | Class File |
Description:
Opens the file with the given mode. If mode is omitted, file is opened for reading and writing with the 'cursor' positioned at the start of the file.
Usage:
$f.open("a"); | $mode | - | Optional mode string. (See "man fopen" for mode descriptions.) |