progetto201 API
|
DISKINFO: manages disk space information. More...
Functions | |
HumanSize ($Bytes) | |
This function changes the measurement unit of bytes. More... | |
Variables | |
$response = array("errors" => array()) | |
Prepare default response array with no errors. More... | |
DISKINFO: manages disk space information.
Client perspective:
The script identifies the OS to choose which is the main partition, uses built-in functions to get free and total space and calculates the occupied space.
After that it uses the HumanSize() function to convert free, total and occupied space in bytes to a human readable unit (for example MB, GB,...).
Finally the data is printed to the client.
Error codes:
HumanSize | ( | $Bytes | ) |
This function changes the measurement unit of bytes.
A loop divides the passed value by 1024 until it gets smaller than 1024. During the loop an index gets incremented to choose the correct measurement unit.
Finally the function rounds the value and returns an array with the value and the measurement unit.
int | $Bytes | bytes to convert in a new measurement unit |
$response = array("errors" => array()) |
Prepare default response array with no errors.