Fix missing methods/method signatures

git-svn-id: http://php-reader.googlecode.com/svn/branches/zend@175 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2010-03-08 09:24:50 +00:00
parent ed2748cf6c
commit 267ed3632d
2 changed files with 84 additions and 6 deletions

View File

@@ -28,7 +28,7 @@
* @author Sven Vollbehr <sven@vollbehr.eu>
* @author Ryan Butterfield <buttza@gmail.com>
* @author Marc Bennewitz <marc-bennewitz@arcor.de>
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@@ -273,6 +273,18 @@ class Zend_Io_Reader
}
}
/**
* Reads 2 bytes from the stream and returns machine ordered binary data
* as signed 16-bit integer.
*
* @return integer
* @throws Zend_Io_Exception if an I/O error occurs
*/
public final function readInt16()
{
return $this->_fromInt16($this->read(2));
}
/**
* Returns machine endian ordered binary data as unsigned 16-bit integer.
*
@@ -313,6 +325,18 @@ class Zend_Io_Reader
return $this->_fromUInt16($this->read(2), self::BIG_ENDIAN_ORDER);
}
/**
* Reads 2 bytes from the stream and returns machine ordered binary data
* as unsigned 16-bit integer.
*
* @return integer
* @throws Zend_Io_Exception if an I/O error occurs
*/
public final function readUInt16()
{
return $this->_fromUInt16($this->read(2), self::MACHINE_ENDIAN_ORDER);
}
/**
* Returns machine-endian ordered binary data as signed 32-bit integer.
*
@@ -355,6 +379,18 @@ class Zend_Io_Reader
return $this->_fromInt32($this->read(4));
}
/**
* Reads 4 bytes from the stream and returns machine ordered binary data
* as signed 32-bit integer.
*
* @return integer
* @throws Zend_Io_Exception if an I/O error occurs
*/
public final function readInt32()
{
return $this->_fromInt32($this->read(4));
}
/**
* Reads 4 bytes from the stream and returns little-endian ordered binary
* data as unsigned 32-bit integer.
@@ -391,6 +427,24 @@ class Zend_Io_Reader
}
}
/**
* Reads 4 bytes from the stream and returns machine ordered binary data
* as unsigned 32-bit integer.
*
* @return integer
* @throws Zend_Io_Exception if an I/O error occurs
*/
public final function readUInt32()
{
if (PHP_INT_SIZE < 8) {
list(, $hi, $lo) = unpack('L*', $this->read(4));
return $hi * (0xffff+1) + $lo; // eq $hi << 16 | $lo
} else {
list(, $int) = unpack('L*', $this->read(4));
return $int;
}
}
/**
* Reads 8 bytes from the stream and returns little-endian ordered binary
* data as 64-bit float.

View File

@@ -57,7 +57,7 @@ require_once 'Zend/Io/FileReader.php';
* @category Zend
* @package Zend_Mime
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@@ -89,7 +89,7 @@ final class Zend_Mime_Magic
* @param string $default The default value.
* @return string|false
*/
public function getType($filename, $default = null)
public function getMimeType($filename, $default = null)
{
$reader = new Zend_Io_FileReader($filename);
@@ -98,8 +98,8 @@ final class Zend_Mime_Magic
$chunks = array();
if (!preg_match("/^(?P<Dependant>>?)(?P<Byte>\d+)\s+(?P<MatchType" .
">\S+)\s+(?P<MatchData>\S+)(?:\s+(?P<MIMEType>[a-" .
"z]+\/[a-z-0-9]+)?(?:\s+(?P<Description>.+))?)?$/",
$line, $chunks)) {
"z]+\/[a-z-0-9]+)?(?:\s+(?P<Description>.?+))?)?$/",
$line, $chunks)) {
continue;
}
@@ -161,10 +161,34 @@ final class Zend_Mime_Magic
return $chunks['MIMEType'];
}
if (!empty($chunks['Description'])) {
return $chunks['Description'];
return rtrim($chunks['Description'], "\n");
}
}
}
return $default;
}
/**
* Returns the results of the mime type check either as a boolean or an
* array of boolean values.
*
* @param string|Array $filename The file path whose type to test.
* @param string|Array $mimeType The mime type to test against.
* @return boolean|Array
*/
public function isMimeType($filename, $mimeType)
{
if (is_array($filename)) {
$result = array();
foreach ($filename as $key => $value) {
$result[] =
($this->getMimeType($value) ==
(is_array($mimeType) ? $mimeType[$key] : $mimeType)) ?
true : false;
}
return $result;
} else {
return $this->getMimeType($filename) == $mimeType ? true : false;
}
}
}