mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 12:34:47 -04:00
Add filesize fallback for large files and 32bit PHP.
This commit is contained in:
parent
d33b0156fc
commit
f9e7e5f9c2
2 changed files with 29 additions and 3 deletions
|
@ -4,12 +4,12 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
|
||||||
var decimalMetric = {
|
var decimalMetric = {
|
||||||
t: 1000.0,
|
t: 1000.0,
|
||||||
k: 1000.0,
|
k: 1000.0,
|
||||||
u: ['B', 'KB', 'MB', 'GB', 'TB']
|
u: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||||
},
|
},
|
||||||
binaryMetric = {
|
binaryMetric = {
|
||||||
t: 1024.0,
|
t: 1024.0,
|
||||||
k: 1024.0,
|
k: 1024.0,
|
||||||
u: ['B', 'KiB', 'MiB', 'GiB', 'TiB']
|
u: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
|
||||||
},
|
},
|
||||||
defaultMetric = decimalMetric,
|
defaultMetric = decimalMetric,
|
||||||
defaultDateFormat = 'YYYY-MM-DD HH:mm',
|
defaultDateFormat = 'YYYY-MM-DD HH:mm',
|
||||||
|
|
|
@ -28,7 +28,33 @@ class Item {
|
||||||
|
|
||||||
if (is_file($path)) {
|
if (is_file($path)) {
|
||||||
|
|
||||||
$size = @filesize($path);
|
if (PHP_INT_SIZE < 8) {
|
||||||
|
$_handle = fopen($path, "r");
|
||||||
|
|
||||||
|
$_pos = 0;
|
||||||
|
$_size = 1073741824;
|
||||||
|
fseek($_handle, 0, SEEK_SET);
|
||||||
|
while ($_size > 1) {
|
||||||
|
fseek($_handle, $_size, SEEK_CUR);
|
||||||
|
|
||||||
|
if (fgetc($_handle) === false) {
|
||||||
|
fseek($_handle, -$_size, SEEK_CUR);
|
||||||
|
$_size = (int)($_size / 2);
|
||||||
|
} else {
|
||||||
|
fseek($_handle, -1, SEEK_CUR);
|
||||||
|
$_pos += $_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (fgetc($_handle) !== false) {
|
||||||
|
$_pos++;
|
||||||
|
}
|
||||||
|
fclose($_handle);
|
||||||
|
|
||||||
|
$size = $_pos * 1e20;
|
||||||
|
} else {
|
||||||
|
$size = @filesize($path);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (is_dir($path)) {
|
} else if (is_dir($path)) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue