[Pkg-owncloud-commits] [owncloud] 130/199: Add LargeFileHelper::__construct() verifying that our assumptions hold.

David Prévot taffit at moszumanska.debian.org
Sun Jun 1 18:53:18 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit a9b28323dd1116aef8c53d8e050380895fa1bb74
Author: Andreas Fischer <bantu at owncloud.com>
Date:   Sat Feb 15 23:41:58 2014 +0100

    Add LargeFileHelper::__construct() verifying that our assumptions hold.
---
 lib/private/largefilehelper.php | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/private/largefilehelper.php b/lib/private/largefilehelper.php
index 66626b4..08869d7 100644
--- a/lib/private/largefilehelper.php
+++ b/lib/private/largefilehelper.php
@@ -13,6 +13,31 @@ namespace OC;
  */
 class LargeFileHelper {
 	/**
+	* pow(2, 53) as a base-10 string.
+	* @var string
+	*/
+	const POW_2_53 = '9007199254740992';
+
+	/**
+	* pow(2, 53) - 1 as a base-10 string.
+	* @var string
+	*/
+	const POW_2_53_MINUS_1 = '9007199254740991';
+
+	/**
+	* @brief Constructor. Checks whether our assumptions hold on the platform
+	*        we are on, throws an exception if they do not hold.
+	*/
+	public function __construct() {
+		$pow_2_53 = floatval(self::POW_2_53_MINUS_1) + 1.0;
+		if ($this->formatUnsignedInteger($pow_2_53) !== self::POW_2_53) {
+			throw new \RunTimeException(
+				'This class assumes floats to be double precision or "better".'
+			);
+		}
+	}
+
+	/**
 	* @brief Formats a signed integer or float as an unsigned integer base-10
 	*        string. Passed strings will be checked for being base-10.
 	*

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list