Exemplo n.º 1
0
        private bool IsCanGrepFile(string file)
        {
            bool result = false;

            if (string.IsNullOrEmpty(file))
            {
                result = false;
            }
            else if (executingFile == file)
            {
                result = false;
            }
            else if (file.ToUpperInvariant().EndsWith(".EXE", StringComparison.CurrentCulture))
            {
                result = false;
            }
            else if (options.IsSetIncludeFiles)
            {
                Regex r = new Regex(WildcardCharacterHelper.TranslateWildcardToRegex(options.IncludeFilesPattern));
                if (r.IsMatch(file))
                {
                    result = true;
                }
            }
            else if (options.IsSetExcludeFiles)
            {
                Regex r = new Regex(WildcardCharacterHelper.TranslateWildcardToRegex(options.ExcludeFilesPattern));
                if (!r.IsMatch(file))
                {
                    result = true;
                }
            }
            else
            {
                result = true;
            }

            return(result);
        }
Exemplo n.º 2
0
        private bool IsCanGrepDirectory(string directory)
        {
            bool result = false;

            if (string.IsNullOrEmpty(directory))
            {
                result = false;
            }
            else if (options.IsSetExcludeDirectories)
            {
                Regex r = new Regex(WildcardCharacterHelper.TranslateWildcardToRegex(options.ExcludeDirectoriesPattern));
                if (!r.IsMatch(directory))
                {
                    result = true;
                }
            }
            else
            {
                result = true;
            }

            return(result);
        }
Exemplo n.º 3
0
        private void StartEncode()
        {
            try
            {
                if (options.IsSetInputFile)
                {
                    string path = WildcardCharacterHelper.TranslateWildcardFilePath(options.InputFile);
                    if (WildcardCharacterHelper.IsContainsWildcard(path))
                    {
                        FileInfo[] files = new DirectoryInfo(Path.GetDirectoryName(path)).GetFiles();
                        foreach (var file in files)
                        {
                            Regex r = new Regex(WildcardCharacterHelper.TranslateWildcardToRegex(path));
                            if (r.IsMatch(file.FullName) || r.IsMatch(file.Name))
                            {
                                EncodeFile(file.FullName);
                            }
                        }
                    }
                    else
                    {
                        EncodeFile(path);
                    }
                }

                if (options.IsSetDirectory)
                {
                    string path = WildcardCharacterHelper.TranslateWildcardDirectoryPath(options.Directory);
                    EncodeDirectory(path);
                }
            }
            catch (CommandLineException ex)
            {
                RaiseCommandLineException(this, ex);
            }
        }