summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 982da7b6cc3..c51629f21cb 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -113,6 +113,35 @@ class OC_HELPER {
$bytes = round( $bytes / 1024, 1 );
return "$bytes GB";
}
+
+ /**
+ * @brief Recusive editing of file permissions
+ * @param $path path to file or folder
+ * @param $filemode unix style file permissions as integer
+ *
+ * Makes 2048 to 2 kB.
+ */
+ function chmodr($path, $filemode) {
+ if (!is_dir($path))
+ return chmod($path, $filemode);
+ $dh = opendir($path);
+ while (($file = readdir($dh)) !== false) {
+ if($file != '.' && $file != '..') {
+ $fullpath = $path.'/'.$file;
+ if(is_link($fullpath))
+ return FALSE;
+ elseif(!is_dir($fullpath) && !chmod($fullpath, $filemode))
+ return FALSE;
+ elseif(!chmodr($fullpath, $filemode))
+ return FALSE;
+ }
+ }
+ closedir($dh);
+ if(chmod($path, $filemode))
+ return TRUE;
+ else
+ return FALSE;
+ }
}
?>