From e0049fc3384317ab508831c290f95cd81a6b64d6 Mon Sep 17 00:00:00 2001 From: svollbehr Date: Mon, 5 Mar 2012 19:06:21 +0000 Subject: [PATCH] Add autoclose of file descriptor git-svn-id: http://php-reader.googlecode.com/svn/trunk@260 51a70ab9-7547-0410-9469-37e369ee0574 --- src/Zend/Media/Iso14496.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Zend/Media/Iso14496.php b/src/Zend/Media/Iso14496.php index 967f0d5..966986c 100644 --- a/src/Zend/Media/Iso14496.php +++ b/src/Zend/Media/Iso14496.php @@ -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. *