public static function chmod($file, $mode, array &$ignored = array())
    {
        if (is_file($file)) {
            if (!chmod($file, $mode)) {
                array_push($ignored, $file);
                return false;
            }

        } else if (is_dir($file)) {
            $items = self::getDirTree($file, true);

            foreach ($items as $item) {
                if (!chmod($item, $mode)) {
                    array_push($ignored, $item);
                }
            }

        } else {
            throw new UnexpectedValueException(sprintf(
                '%s expects a path to be a directory or a file as first argument', __METHOD__
            ));
        }

        return true;
    }