summaryrefslogtreecommitdiffstats
path: root/provision.inc
diff options
context:
space:
mode:
authorAntoine Beaupré2011-04-07 19:41:36 (GMT)
committerAntoine Beaupré2011-04-07 19:53:57 (GMT)
commitf6d53f440818d5b54bce38a9ea7a3f9b64f149ac (patch)
treefc5bc765459dcf66d6e6a5c2d13bb33eac5a8a60 /provision.inc
parent137ecd9f9f60d2731b4130bb7e2053a263d982cd (diff)
port our recursive_delete() function to drupal 7's
improvements; * we close directories as we go * coding style
Diffstat (limited to 'provision.inc')
-rw-r--r--provision.inc9
1 files changed, 7 insertions, 2 deletions
diff --git a/provision.inc b/provision.inc
index 4c610f5..c46055a 100644
--- a/provision.inc
+++ b/provision.inc
@@ -118,17 +118,21 @@ function provision_save_platform_data() {
/**
* Remove files or directories, recursively
*
- * This was taken from imagecache.module, with slight modifications:
+ * This was taken from Drupal 7's file.inc, with slight modifications:
* - carry error codes along the way (returns TRUE only if all operations return TRUE)
* - remove any type of files encountered (not just links, files and dirs)
* - safety checking since we don't necessarly trust the removed files
+ *
+ * @see file_unmanaged_delete_recursive()
*/
function _provision_recursive_delete($path) {
$ret = 1;
if (is_dir($path)) {
$d = dir($path);
while (($entry = $d->read()) !== FALSE) {
- if ($entry == '.' || $entry == '..') continue;
+ if ($entry == '.' || $entry == '..') {
+ continue;
+ }
$entry_path = $path .'/'. $entry;
if (_provision_file_check_location($entry_path, $path)) {
$ret = _provision_recursive_delete($entry_path);
@@ -137,6 +141,7 @@ function _provision_recursive_delete($path) {
$ret = 0;
}
}
+ $d->close();
$rm = provision_file()->rmdir($path)
->succeed('Deleting @path directory successful.')