Add autoclose of file descriptor

git-svn-id: http://php-reader.googlecode.com/svn/trunk@260 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2012-03-05 19:06:21 +00:00
parent 4797da8f78
commit e0049fc338

View File

@@ -256,6 +256,9 @@ final class Zend_Media_Iso14496 extends Zend_Media_Iso14496_Box
/** @var string */
private $_filename;
/** @var boolean */
private $_autoClose = false;
/**
* Constructs the Zend_Media_Iso14496 class with given file and options.
*
@@ -283,6 +286,7 @@ final class Zend_Media_Iso14496 extends Zend_Media_Iso14496_Box
require_once 'Zend/Io/FileReader.php';
try {
$this->_reader = new Zend_Io_FileReader($filename);
$this->_autoClose = true;
} catch (Zend_Io_Exception $e) {
$this->_reader = null;
require_once 'Zend/Media/Iso14496/Exception.php';
@@ -300,6 +304,17 @@ final class Zend_Media_Iso14496 extends Zend_Media_Iso14496_Box
$this->constructBoxes();
}
/**
* Closes down the reader.
*/
public function __destruct()
{
parent::__destruct();
if ($this->_autoClose === true && $this->_reader !== null) {
$this->_reader->close();
}
}
/**
* Writes the changes back to given media file.
*