protected function createCacheDirectory($path): bool
    {
        if (
            !$path
            ||
            $path === '/'
            ||
            $path === '.'
            ||
            $path === '\\'
        ) {
            return false;
        }

        // if the directory already exists, just return true
        if (\is_dir($path) && \is_writable($path)) {
            return true;
        }

        // if more than one level, try parent first
        if (\dirname($path) !== '.') {
            $return = $this->createCacheDirectory(\dirname($path));
            // if creating parent fails, we can abort immediately
            if (!$return) {
                return false;
            }
        }

        $mode_dec = \intval($this->fileMode, 8);
        $old_umask = \umask(0);

        /** @noinspection PhpUsageOfSilenceOperatorInspection */
        if (!@\mkdir($path, $mode_dec) && !\is_dir($path)) {
            $return = false;
        } else {
            $return = true;
        }

        if (\is_dir($path) && !\is_writable($path)) {
            $return = \chmod($path, $mode_dec);
        }

        \umask($old_umask);

        return $return;
    }