Skip to content

Commit 1761908

Browse files
committed
use fulldelete function in filelib.php to delete dir
1 parent cecd287 commit 1761908

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

modules/git_command.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
require_once($CFG->libdir.'/filelib.php');
4+
35
class git_command {
46

57
private $workspace;
@@ -128,7 +130,7 @@ public function delete($pattern) {
128130
foreach($worktrees as $worktree) {
129131
if ($worktree != '.' && $worktree != '..') {
130132
if (preg_match($pattern, $worktree)) {
131-
$this->delete_dir($this->workspace.'/'.$worktree);
133+
fulldelete($this->workspace.'/'.$worktree);
132134
}
133135
}
134136
}
@@ -148,24 +150,4 @@ public function run($dir, $command, $param_string) {
148150

149151
return trim($output);
150152
}
151-
152-
private function delete_dir($dir) {
153-
154-
$dir = rtrim($dir, '/');
155-
if (!is_dir($dir)) {
156-
return;
157-
}
158-
$objects = scandir($dir);
159-
foreach($objects as $object) {
160-
if ($object != '.' && $object != '..') {
161-
$target = $dir.'/'.$object;
162-
if (filetype($target) == 'dir') {
163-
$this->delete_dir($target);
164-
} else {
165-
unlink($target);
166-
}
167-
}
168-
}
169-
rmdir($dir);
170-
}
171153
}

0 commit comments

Comments
 (0)