From 57efd9a7ae27b2f0bd98382a1f6b107064585f99 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Sun, 8 Nov 2020 17:51:28 +0100 Subject: Move delete_directory() into Plugin class It was the only place it was used --- ratatoeskr/sys/models.php | 29 ++++++++++++++++++++++++++--- ratatoeskr/sys/utils.php | 23 ----------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ratatoeskr/sys/models.php b/ratatoeskr/sys/models.php index 613334f..d2ed544 100644 --- a/ratatoeskr/sys/models.php +++ b/ratatoeskr/sys/models.php @@ -1590,6 +1590,29 @@ class Plugin ); } + /** + * Delete a directory and all of its content. + * @param string $dir + */ + private static function delete_directory(string $dir): void + { + $dir_content = scandir($dir); + foreach ($dir_content as $f) { + if (($f == "..") or ($f == ".")) { + continue; + } + + $f = "$dir/$f"; + + if (is_dir($f)) { + self::delete_directory($f); + } else { + unlink($f); + } + } + rmdir($dir); + } + public function delete(?Database $db = null): void { $db = $db ?? Env::getGlobal()->database(); @@ -1606,13 +1629,13 @@ class Plugin } if (is_dir(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/private/" . $this->id)) { - delete_directory(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/private/" . $this->id); + self::delete_directory(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/private/" . $this->id); } if (is_dir(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/public/" . $this->id)) { - delete_directory(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/public/" . $this->id); + self::delete_directory(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/public/" . $this->id); } if (is_dir(SITE_BASE_PATH . "/ratatoeskr/templates/src/plugintemplates/" . $this->id)) { - delete_directory(SITE_BASE_PATH . "/ratatoeskr/templates/src/plugintemplates/" . $this->id); + self::delete_directory(SITE_BASE_PATH . "/ratatoeskr/templates/src/plugintemplates/" . $this->id); } } } diff --git a/ratatoeskr/sys/utils.php b/ratatoeskr/sys/utils.php index 60f90a8..5e0415c 100644 --- a/ratatoeskr/sys/utils.php +++ b/ratatoeskr/sys/utils.php @@ -10,29 +10,6 @@ * See "ratatoeskr/licenses/ratatoeskr" for more information. */ -/* - * Function: delete_directory - * Delete a directory and all of its content. - */ -function delete_directory($dir) -{ - $dir_content = scandir($dir); - foreach ($dir_content as $f) { - if (($f == "..") or ($f == ".")) { - continue; - } - - $f = "$dir/$f"; - - if (is_dir($f)) { - delete_directory($f); - } else { - unlink($f); - } - } - rmdir($dir); -} - /* * Constant: SITE_BASE_PATH * The Base path of this ratatoeskr site. -- cgit v1.2.3-54-g00ecf