lemurro / lib-diskspace
PHP库 DiskSpace - 检查磁盘可用空间
v0.1.0
2018-07-01 13:05 UTC
Requires
- php: >=7.0.0
- gabrielelana/byte-units: ^0.5
This package is auto-updated.
Last update: 2024-09-15 03:08:44 UTC
README
* 仅适用于基于Unix的系统
检查磁盘可用空间
安装
composer require lemurro/lib-diskspace
使用
$disk_space = new \Lemurro\Lib\DiskSpace\DiskSpace(); // Лимит свободного места, в бинарной системе основанной на 1024-байтах в килобайте // Суффиксы: KiB, MiB, GiB, TiB, PiB, … // По умолчанию: '1GiB' $result = $disk_space->check('50GiB'); //Array //( // [data] => Array // ( // [limit_exceeded] => true // [free_space] => 43.2 GiB // [space_limit] => 50.0 GiB // ) //) $result = $disk_space->check('30GiB'); //Array //( // [data] => Array // ( // [limit_exceeded] => false // [free_space] => 43.2 GiB // [space_limit] => 30.0 GiB // ) //)
错误
如果出现错误,将返回包含元素 errors
的数组
Array
(
[errors] => Array
(
[status] => '400 Bad Request'
[code] => 'warning'
[title] => 'Не удалось преобразовать указанный лимит в байты'
[meta] => Array
(
[space_limit_string] => '50 abc'
)
)
)