mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/15342] Add method to get free space
PHPBB3-15342
This commit is contained in:
parent
bb0d705ebf
commit
4cff370f8d
3 changed files with 41 additions and 0 deletions
|
@ -95,4 +95,13 @@ interface adapter_interface
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function get_link($path);
|
public function get_link($path);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get space available in bytes.
|
||||||
|
*
|
||||||
|
* @throws \phpbb\storage\exception\exception When can't get available space
|
||||||
|
*
|
||||||
|
* @return int Returns available space
|
||||||
|
*/
|
||||||
|
public function free_space();
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,4 +424,23 @@ class local implements adapter_interface, stream_interface
|
||||||
{
|
{
|
||||||
return generate_board_url() . $this->path . $path;
|
return generate_board_url() . $this->path . $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get space available in bytes.
|
||||||
|
*
|
||||||
|
* @throws \phpbb\storage\exception\exception When can't get available space
|
||||||
|
*
|
||||||
|
* @return int Returns available space
|
||||||
|
*/
|
||||||
|
public function free_space()
|
||||||
|
{
|
||||||
|
$free_space = @disk_free_space($this->root_path);
|
||||||
|
|
||||||
|
if ($free_space === false)
|
||||||
|
{
|
||||||
|
throw new exception('STORAGE_CANNOT_GET_FREE_SPACE');
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) $free_space;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,4 +360,17 @@ class storage
|
||||||
|
|
||||||
return $number_files;
|
return $number_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get space available in bytes.
|
||||||
|
*
|
||||||
|
* @throws \phpbb\storage\exception\exception When can't get available space
|
||||||
|
*
|
||||||
|
* @return int Returns available space
|
||||||
|
*/
|
||||||
|
public function free_space()
|
||||||
|
{
|
||||||
|
return $this->get_adapter()->free_space();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue