public static function chmod(
        $path = null, $mode = self::DEFAULT_UNIX_CHMOD_DIRECTORIES,
        $recursive = true, $file_mode = self::DEFAULT_UNIX_CHMOD_FILES, array &$logs = array()
    ){
        if (is_null($path)) {
            return null;
        }
        $ok = false;
        if (file_exists($path) && is_dir($path)) {
            if (true!==($ok = chmod($path, Filesystem::getOctal($mode)))) {
                $logs[] = sprintf('Can not change mode on directory "%s" (trying to set them on "%d").', $path, $mode);
            }
            if ($ok && true===$recursive) {
                $iterator = new \RecursiveIteratorIterator(
                    new \RecursiveDirectoryIterator($path), 
                    \RecursiveIteratorIterator::SELF_FIRST | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS
                );
                foreach($iterator as $item) {
                    if (in_array($item->getFilename(), array('.', '..'))) {
                        continue;
                    }
                    if ($item->isDir()) {
                        if (true!==($ok = chmod($item, Filesystem::getOctal($mode)))) {
                            $logs[] = sprintf('Can not change mode on sub-directory "%s" (trying to set them on "%d").', $item, $mode);
                        }
                    } elseif ($item->isFile() && !$item->isLink()) {
                        if (true!==($ok = chmod($item, Filesystem::getOctal($file_mode)))) {
                            $logs[] = sprintf('Can not change mode on file "%s" (trying to set them on "%d").', $item, $file_mode);
                        }
                    }
                } 
            }
            clearstatcache();
        } else {
            $logs[] = sprintf('Directory "%s" not found (can not change mode).', $path);
        }
        return $ok;
    }