mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-19 12:00:01 +01:00
Add filesize fallback for large files and 32bit PHP.
This commit is contained in:
parent
d33b0156fc
commit
f9e7e5f9c2
@ -4,12 +4,12 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
|
||||
var decimalMetric = {
|
||||
t: 1000.0,
|
||||
k: 1000.0,
|
||||
u: ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
u: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||
},
|
||||
binaryMetric = {
|
||||
t: 1024.0,
|
||||
k: 1024.0,
|
||||
u: ['B', 'KiB', 'MiB', 'GiB', 'TiB']
|
||||
u: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
|
||||
},
|
||||
defaultMetric = decimalMetric,
|
||||
defaultDateFormat = 'YYYY-MM-DD HH:mm',
|
||||
|
@ -28,7 +28,33 @@ class Item {
|
||||
|
||||
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)) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user