forked from zacharydanger/git-phing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitTask.php
executable file
·56 lines (50 loc) · 1.04 KB
/
GitTask.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require_once 'phing/Task.php';
/**
* Base class for Git Tasks.
*
* @author Zach Campbell <zacharydangercampbell@gmail.com>
*/
class GitTask extends Task {
/**
* Path to git executable.
*/
public $git_path = 'git';
/**
* Main initialization, does nothing.
*/
public function init() { /* do nothing */ }
/**
* Optionally set the path to git.
*/
public function setGitPath($git_path) {
$this->git_path = $git_path;
}
/**
* Main entry. Does nothing.
*/
public function main() { /* do nothing */ }
/**
* Recursively delete a directory and its children
* @param string $dir Directory to delete
*/
protected function recursiveRmDir($dir) {
if ( is_dir($dir) ) {
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if ( ! $this->recursiveRmDir($dir . '/' . $file) ) {
return false;
}
}
}
closedir($handle);
return rmdir($dir);
} elseif ( is_file($dir) ) {
return unlink($dir);
} else {
return false;
}
}
}
?>