diff --git a/phpBB/phpbb/storage/adapter/adapter_interface.php b/phpBB/phpbb/storage/adapter/adapter_interface.php index d57c2ba587..96617c8e6a 100644 --- a/phpBB/phpbb/storage/adapter/adapter_interface.php +++ b/phpBB/phpbb/storage/adapter/adapter_interface.php @@ -95,4 +95,13 @@ interface adapter_interface * */ 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(); } diff --git a/phpBB/phpbb/storage/adapter/local.php b/phpBB/phpbb/storage/adapter/local.php index bfcdebc565..fd0fbe84d8 100644 --- a/phpBB/phpbb/storage/adapter/local.php +++ b/phpBB/phpbb/storage/adapter/local.php @@ -424,4 +424,23 @@ class local implements adapter_interface, stream_interface { 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; + } } diff --git a/phpBB/phpbb/storage/storage.php b/phpBB/phpbb/storage/storage.php index 91f08c50f4..327bb60ab1 100644 --- a/phpBB/phpbb/storage/storage.php +++ b/phpBB/phpbb/storage/storage.php @@ -360,4 +360,17 @@ class storage 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(); + } + }