root

Changeset 551

Show
Ignore:
Timestamp:
05/03/09 22:12:27 (1 year ago)
Author:
wbond
Message:

Fixed ticket #179, added fFile::__sleep() and fFile::__wakeup() methods

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fFile.php

    r540 r551 Hide Line Numbers
    1010 * @link       http://flourishlib.com/fFile 
    1111 *  
    12  * @version    1.0.0b16 
     12 * @version    1.0.0b17 
     13 * @changes    1.0.0b17  Added ::__sleep() and ::__wakeup() for proper serialization with the filesystem map [wb, 2009-05-03] 
    1314 * @changes    1.0.0b16  ::output() now accepts `TRUE` in the second parameter to use the current filename as the attachment filename [wb, 2009-03-23] 
    1415 * @changes    1.0.0b15  Added support for mime type detection of MP3s based on the MPEG-2 (as opposed to MPEG-1) standard [wb, 2009-03-23] 
     
    535536     
    536537    /** 
     538     * The iterator information doesn't need to be serialized since a resource can't be 
     539     * 
     540     * @return array  The instance variables to serialize 
     541     */ 
     542    public function __sleep() 
     543    { 
     544        if ($this->file_handle) { 
     545            fclose($this->file_handle); 
     546            $this->current_line        = NULL; 
     547            $this->current_line_number = NULL; 
     548            $this->file_handle         = NULL;   
     549        } 
     550        return array('exception', 'file'); 
     551    } 
     552     
     553     
     554    /** 
    537555     * Returns the filename of the file 
    538556     *  
     
    542560    { 
    543561        return $this->getFilename(); 
     562    } 
     563     
     564     
     565    /** 
     566     * Re-inserts the file back into the filesystem map when unserialized 
     567     * 
     568     * @return void 
     569     */ 
     570    public function __wakeup() 
     571    { 
     572        $file      = $this->file; 
     573        $exception = $this->exception; 
     574         
     575        $this->file      =& fFilesystem::hookFilenameMap($file); 
     576        $this->exception =& fFilesystem::hookExceptionMap($file); 
     577         
     578        if ($exception !== NULL) { 
     579            fFilesystem::updateExceptionMap($file, $exception); 
     580        } 
    544581    } 
    545582