private boolean isBinary(final ClientServices client, final String filename,
                    final Map<StringPattern, KeywordSubstitutionOptions> directoryLevelWrappers)
                    throws CommandException {
        KeywordSubstitutionOptions keywordSubstitutionOptions = getKeywordSubst();

        if (keywordSubstitutionOptions == KeywordSubstitutionOptions.BINARY) {
            return true;
        }

        // The keyWordSubstitutions was set based on MIME-types by
        // CVSAdd which had no notion of cvswrappers. Therefore some
        // filetypes returned as text may actually be binary within CVS
        // We check for those files here

        boolean wrapperFound = false;

        if (wrapperMap == null) {
            // process the wrapper settings as we have not done it before.
            wrapperMap = WrapperUtils.mergeWrapperMap(client);
        }

        for (final StringPattern stringPattern : wrapperMap.keySet()) {
            final SimpleStringPattern pattern = (SimpleStringPattern) stringPattern;
            if (pattern.doesMatch(filename)) {
                keywordSubstitutionOptions = wrapperMap.get(pattern);
                wrapperFound = true;
                break;
            }
        }

        // if no wrappers are found to match the server and local settings, try
        // the wrappers for this local directory
        if (!wrapperFound && (directoryLevelWrappers != null) && (directoryLevelWrappers != EMPTYWRAPPER)) {
            for (final StringPattern stringPattern : directoryLevelWrappers.keySet()) {
                final SimpleStringPattern pattern = (SimpleStringPattern) stringPattern;
                if (pattern.doesMatch(filename)) {
                    keywordSubstitutionOptions = directoryLevelWrappers.get(pattern);
                    wrapperFound = true;
                    break;
                }
            }
        }

        return keywordSubstitutionOptions == KeywordSubstitutionOptions.BINARY;
    }