aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/largefilehelper.php
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2014-02-15 23:41:58 +0100
committerAndreas Fischer <bantu@owncloud.com>2014-05-29 16:26:01 +0200
commita9b28323dd1116aef8c53d8e050380895fa1bb74 (patch)
tree1788b2425c59c13a340f777c4d7169f8ac3b5978 /lib/private/largefilehelper.php
parent2c36a4b07a088bca4f20c2f6386765dfc8ad07b7 (diff)
downloadnextcloud-server-a9b28323dd1116aef8c53d8e050380895fa1bb74.tar.gz
nextcloud-server-a9b28323dd1116aef8c53d8e050380895fa1bb74.zip
Add LargeFileHelper::__construct() verifying that our assumptions hold.
Diffstat (limited to 'lib/private/largefilehelper.php')
-rw-r--r--lib/private/largefilehelper.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/private/largefilehelper.php b/lib/private/largefilehelper.php
index 66626b4a7fe..08869d7c82a 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.
*