Cast to numeric instead of float, i.e. use an integer if possible.

This commit is contained in:
Andreas Fischer 2014-01-07 13:50:57 +01:00
parent 6195f13bda
commit 3f8f8027d2
1 changed files with 6 additions and 6 deletions

View File

@ -224,7 +224,7 @@ if (\OC_Util::runningOnWindows()) {
/**
* @brief Tries to get the filesize via various workarounds if necessary.
* @param string $fullPath
* @return mixed Number of bytes as float on success and workaround necessary, null otherwise.
* @return mixed Number of bytes on success and workaround necessary, null otherwise.
*/
private static function getFileSizeWithTricks($fullPath) {
if (PHP_INT_SIZE === 4) {
@ -249,7 +249,7 @@ if (\OC_Util::runningOnWindows()) {
/**
* @brief Tries to get the filesize via a CURL HEAD request.
* @param string $fullPath
* @return mixed Number of bytes as float on success, null otherwise.
* @return mixed Number of bytes on success, null otherwise.
*/
private static function getFileSizeFromCurl($fullPath) {
if (function_exists('curl_init')) {
@ -263,7 +263,7 @@ if (\OC_Util::runningOnWindows()) {
$matches = array();
preg_match('/Content-Length: (\d+)/', $data, $matches);
if (isset($matches[1])) {
return (float) $matches[1];
return 0 + $matches[1];
}
}
}
@ -274,7 +274,7 @@ if (\OC_Util::runningOnWindows()) {
/**
* @brief Tries to get the filesize via COM and exec().
* @param string $fullPath
* @return mixed Number of bytes as float on success, null otherwise.
* @return mixed Number of bytes on success, null otherwise.
*/
private static function getFileSizeFromOS($fullPath) {
$name = strtolower(php_uname('s'));
@ -287,11 +287,11 @@ if (\OC_Util::runningOnWindows()) {
}
} else if (strpos($name, 'bsd') !== false) {
if (\OC_Helper::is_function_enabled('exec')) {
return (float)exec('stat -f %z ' . escapeshellarg($fullPath));
return 0 + exec('stat -f %z ' . escapeshellarg($fullPath));
}
} else if (strpos($name, 'linux') !== false) {
if (\OC_Helper::is_function_enabled('exec')) {
return (float)exec('stat -c %s ' . escapeshellarg($fullPath));
return 0 + exec('stat -c %s ' . escapeshellarg($fullPath));
}
} else {
\OC_Log::write('core',