forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.inc
45 lines (38 loc) · 1.02 KB
/
utils.inc
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
<?php
function dump_entries_name($z) {
for($i=0; $i<$z->numFiles; $i++) {
$sb = $z->statIndex($i);
echo $i . ' ' . $sb['name'] . "\n";
}
}
function verify_entries($zip, $entries = []) {
$verified = true;
$found = [];
for ($index = 0; $index < $zip->numFiles; $index++) {
$stat = $zip->statIndex($index);
if (!in_array($stat["name"], $entries)) {
$verified = false;
}
$found[] = $stat["name"];
}
if (!$verified) {
var_dump($found);
}
return $verified;
}
/* recursively remove a directory */
function rmdir_rf($dir) {
if ($handle = opendir($dir)) {
while (false !== ($item = readdir($handle))) {
if ($item != "." && $item != "..") {
if (is_dir($dir . '/' . $item)) {
rmdir_rf($dir . '/' . $item);
} else {
unlink($dir . '/' . $item);
}
}
}
closedir($handle);
rmdir($dir);
}
}