User management for the world wide web

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

GenieGate_TempWriter Class Reference

GenieGate_TempWriter Utility class for opening files with intention to be edit. More...

List of all members.

Public Member Functions

 GenieGate_TempWriter ($filename)
 constructor, this creates the object.

 getFilename ()
 Get the filename.

 getRead ()
 Get the read handle.

 getWrite ()
 Get the write handle.

 cancel ()
 Attempts to "cancel" the operation.

 isCanceled ()
 Return TRUE if the operation has been cancelled.

 complete ()
 Call this method when finished editing.


Detailed Description

GenieGate_TempWriter Utility class for opening files with intention to be edit.

The idea is to perform an edit with some type "cancel" function, and an attempt to recover from errors.

The basic idea is: open read file. lock read file. create temp file (for writing to)

read + write data ( getWrite() , getRead() )

call complete() complete will rename the read file to a backup file, attempt to rename the temp file to the original file, unlink the backup file.

NOTE: this implementation doesn't rename the original file until after all editing is done, so that existing processes can read the file while we're working on it.

Definition at line 29 of file utils.php.


Constructor & Destructor Documentation

GenieGate_TempWriter filename  ) 
 

constructor, this creates the object.

If the filename does not exist, it will be created.

Parameters:
$filename - The file to read/write to.

Definition at line 46 of file utils.php.

References cancel().


Member Function Documentation

cancel  ) 
 

Attempts to "cancel" the operation.

This will close the file handles, unlock and remove temp data.

Data will not be saved.

Definition at line 92 of file utils.php.

Referenced by GenieGate_TempWriter().

complete  ) 
 

Call this method when finished editing.

It attempts to move the data from the write handle to the reader, with some primitive error recovery.

Definition at line 125 of file utils.php.

References isCanceled().

getRead  ) 
 

Get the read handle.

Returns:
File handle for reading, or FALSE if could not be opened.

Definition at line 77 of file utils.php.

getWrite  ) 
 

Get the write handle.

Returns:
File handle for writing, or FALSE if reader or writer could not be opened.

Definition at line 83 of file utils.php.


The documentation for this class was generated from the following file:
DoxyGen Documentation generated by DoxyGen