Skip to content

Commit

Permalink
move function into class
Browse files Browse the repository at this point in the history
Signed-off-by: CaCO3 <caco@ruinelli.ch>
  • Loading branch information
caco3 authored and CaCO3 committed Oct 26, 2023
1 parent 5993cc6 commit f13384d
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,6 @@ public function accept(): bool {
}


function rrmdir($src) {
$dir = opendir($src);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
$full = $src . '/' . $file;
if ( is_dir($full) ) {
rrmdir($full);
}
else {
unlink($full);
}
}
}
closedir($dir);
rmdir($src);
}


class Updater {
private string $baseDir;
private array $configValues = [];
Expand Down Expand Up @@ -149,6 +131,26 @@ public function __construct(string $baseDir) {
$this->buildTime = $buildTime;
}

/**
* Deletes a directory recursively
*/
private function rrmdir(string $src): void {
$dir = opendir($src);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
$full = $src . '/' . $file;
if ( is_dir($full) ) {
rrmdir($full);
}
else {
unlink($full);
}
}
}
closedir($dir);
rmdir($src);
}

/**
* Returns whether the web updater is disabled
*
Expand Down

0 comments on commit f13384d

Please sign in to comment.