- Timestamp:
- 11/14/09 10:16:10 (4 months ago)
- Files:
-
- fFilesystem.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
fFilesystem.php
r696 r732 Hide Line Numbers 3 3 * Handles filesystem-level tasks including filesystem transactions and the reference map to keep all fFile and fDirectory objects in sync 4 4 * 5 * @copyright Copyright (c) 2008-2009 Will Bond 5 * @copyright Copyright (c) 2008-2009 Will Bond, others 6 6 * @author Will Bond [wb] <will@flourishlib.com> 7 * @author Alex Leeds [al] <alex@kingleeds.com> 7 8 * @license http://flourishlib.com/license 8 9 * … … 10 11 * @link http://flourishlib.com/fFilesystem 11 12 * 12 * @version 1.0.0b11 13 * @version 1.0.0b12 14 * @changes 1.0.0b12 Updated ::convertToBytes() to properly handle integers without a suffix and sizes with fractions [al+wb, 2009-11-14] 13 15 * @changes 1.0.0b11 Corrected the API documentation for ::getPathInfo() [wb, 2009-09-09] 14 16 * @changes 1.0.0b10 Updated ::updateExceptionMap() to not contain the Exception class parameter hint, allowing NULL to be passed [wb, 2009-08-20] … … 167 169 * Takes a file size including a unit of measure (i.e. kb, GB, M) and converts it to bytes 168 170 * 171 * Sizes are interpreted using base 2, not base 10. Sizes above 2GB may not 172 * be accurately represented on 32 bit operating systems. 173 * 169 174 * @param string $size The size to convert to bytes 170 175 * @return integer The number of bytes represented by the size … … 172 177 static public function convertToBytes($size) 173 178 { 174 if (!preg_match('#^(\d+ )\s*(k|m|g|t)?(ilo|ega|era|iga)?( )?b?(yte(s)?)?$#D', strtolower(trim($size)), $matches)) {179 if (!preg_match('#^(\d+(?:\.\d+)?)\s*(k|m|g|t)?(ilo|ega|era|iga)?( )?b?(yte(s)?)?$#D', strtolower(trim($size)), $matches)) { 175 180 throw new fProgrammerException( 176 181 'The size specified, %s, does not appears to be a valid size', … … 179 184 } 180 185 181 if ( $matches[2] == '') {186 if (empty($matches[2])) { 182 187 $matches[2] = 'b'; 183 188 } … … 188 193 'g' => 1073741824, 189 194 't' => 1099511627776); 190 return $matches[1] * $size_map[$matches[2]];195 return round($matches[1] * $size_map[$matches[2]]); 191 196 } 192 197 … … 663 668 664 669 /** 665 * Copyright (c) 2008-2009 Will Bond <will@flourishlib.com> 670 * Copyright (c) 2008-2009 Will Bond <will@flourishlib.com>, others 666 671 * 667 672 * Permission is hereby granted, free of charge, to any person obtaining a copy
