public function chmod($path, $mode = false, $recursive = true, $exceptions = array())
    {
        if (!$mode) {
            $mode = $this->mode;
        }

        if ($recursive === false && is_dir($path)) {
            //@codingStandardsIgnoreStart
            if (@chmod($path, intval($mode, 8))) {
                //@codingStandardsIgnoreEnd
                $this->_messages[] = __d('cake_dev', '%s changed to %s', $path, $mode);

                return true;
            }

            $this->_errors[] = __d('cake_dev', '%s NOT changed to %s', $path, $mode);

            return false;
        }

        if (is_dir($path)) {
            $paths = $this->tree($path);

            foreach ($paths as $type) {
                foreach ($type as $fullpath) {
                    $check = explode(DS, $fullpath);
                    $count = count($check);

                    if (in_array($check[$count - 1], $exceptions)) {
                        continue;
                    }

                    //@codingStandardsIgnoreStart
                    if (@chmod($fullpath, intval($mode, 8))) {
                        //@codingStandardsIgnoreEnd
                        $this->_messages[] = __d('cake_dev', '%s changed to %s', $fullpath, $mode);
                    } else {
                        $this->_errors[] = __d('cake_dev', '%s NOT changed to %s', $fullpath, $mode);
                    }
                }
            }

            if (empty($this->_errors)) {
                return true;
            }
        }

        return false;
    }