private function isRecursivelyWritable($path)
{
$path = rtrim((string) $path, '/');
// check if path is writable
if (!$this->isWritable($path)) {
return false;
}
// loop child directories
foreach ((array) scandir($path) as $file) {
// no '.' and '..'
if ($file != '.' && $file != '..') {
// directory
if (is_dir($path . '/' . $file)) {
// check if children are readable
if (!$this->isRecursivelyWritable($path . '/' . $file)) {
return false;
}
}
}
}
// we were able to read all sub-directories
return true;
}