Exemple #1
0
        public override string[] ExtractTargets(string target)
        {
            List <string> results = new List <string>();

            // get subdirectories and return the ones that aren't ignored
            if (Directory.Exists(target))
            {
                DirectoryInfo dir = new DirectoryInfo(target);
                AddFoldersToBeIgnored(dir);

                dir.GetDirectories()
                .Select(d => d.FullName)
                .Each(t =>
                {
                    if (!IgnoreFolders.Contains(t))
                    {
                        results.Add(t);
                    }
                });

                AddFilesToBeIgnored(dir);

                dir.GetFiles(Config.TargetFilePattern)
                .Select(f => f.FullName)
                .Each(t =>
                {
                    if (!IgnoreFiles.Contains(t))
                    {
                        results.Add(new FileInfo(t).FullName);
                    }
                });
            }
            return(results.ToArray());
        }
 private List <string> GetSubFolders(string rootFolder)
 {
     return(Directory.GetDirectories(rootFolder)
            .Select(Path.GetFileName)
            .Where(d => !d.StartsWith(".") && !IgnoreFolders.Contains(d, StringComparer.InvariantCultureIgnoreCase))
            .OrderBy(d => d, StringComparer.InvariantCultureIgnoreCase)
            .ToList());
 }
Exemple #3
0
 private void AddFoldersToBeIgnored(DirectoryInfo dir)
 {
     if (Config.IgnoreFolderPatterns != null && Config.IgnoreFolderPatterns.Length > 0)
     {
         Config.IgnoreFolderPatterns.Each(ignoreFolder =>
         {
             dir.GetDirectories(ignoreFolder)
             .Select(d => d.FullName)
             .Each(d => IgnoreFolders.Add(d));
         });
     }
 }
Exemple #4
0
        private static void ParseOptions(string[] args)
        {
            var options = args.Where(a => a.StartsWith("-")).ToList();

            ParseOption(options, "-a", o => ShowAll = true);
            ParseOption(options, "-h", o => Help    = true);
            ParseOption(options, "-i=",
                        o => IgnoreFolders.AddRange(o.Substring(3).Split(',')),
                        () => IgnoreFolders.AddRange(IgnoreFoldersDefault));

            if (options.Any())
            {
                throw new CmdLnException("Unknown command line option(s): " + string.Join(" ", options));
            }
        }
Exemple #5
0
        private void SetEnvironments()
        {
            {
                List <string> rawLines;
                if (Environment.Is64BitProcess)
                {
                    rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(SYSTEMENVIRONMENTS_x64_FILE));
                }
                else
                {
                    rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(SYSTEMENVIRONMENTS_x86_FILE));
                }

                foreach (var item in rawLines)
                {
                    int tipStartPos = item.IndexOf(',');
                    var envVariable = item.Substring(0, tipStartPos);
                    var nextSection = item.Substring(tipStartPos + 1);
                    tipStartPos = nextSection.IndexOf(',');
                    var envValue = nextSection.Substring(0, tipStartPos);
                    nextSection = nextSection.Substring(tipStartPos + 1);
                    tipStartPos = nextSection.IndexOf(',');
                    var displayName = nextSection.Substring(0, tipStartPos);
                    var envTips     = nextSection.Substring(tipStartPos + 1);

                    ToolTipMap.Add(envVariable, envTips);

                    var filePath = new Model.EnvironmentInfo();
                    filePath.VarName      = envVariable;
                    filePath.Tips         = envTips;
                    filePath.DisplayName  = displayName;
                    filePath.RelativePath = envValue;
                    filePath.ShortPath    = envValue.GetAbsolutePath(true);
                    filePath.LongPath     = envValue.GetAbsolutePath(false);

                    SystemEnvironments.Add(envVariable, filePath);
                }
            }

            {
                var rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(APPENVIRONMENTS_FILE));

                foreach (var item in rawLines)
                {
                    int tipStartPos = item.IndexOf(',');

                    var envVariable = item.Substring(0, tipStartPos);
                    var envTips     = item.Substring(tipStartPos);

                    ToolTipMap.Add(envVariable, envTips);

                    var filePath = new Model.EnvironmentInfo();
                    filePath.RelativePath = envVariable;
                    filePath.ShortPath    = envVariable.GetAbsolutePath(true);
                    filePath.LongPath     = envVariable.GetAbsolutePath(false);

                    AppEnvironments.Add(envVariable, filePath);
                }
            }

            {
                var rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(IGNOREFOLDERS_FILE));

                foreach (var item in rawLines)
                {
                    var expandedValue = Environment.ExpandEnvironmentVariables(item);

                    var filePath = new Model.FilePath();
                    filePath.RelativePath = item;
                    filePath.ShortPath    = expandedValue;
                    filePath.LongPath     = string.Format(@"\\?\{0}", expandedValue);

                    IgnoreFolders.Add(filePath);
                }
            }

            {
                var rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(IGNOREFILES_FILE));

                foreach (var item in rawLines)
                {
                    var expandedValue = Environment.ExpandEnvironmentVariables(item);

                    var filePath = new Model.FilePathEx();
                    filePath.RelativePath = item;
                    filePath.ShortPath    = new Regex(expandedValue.Replace("\\", "\\\\"),
                                                      RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.Compiled);
                    var tempVal = string.Format(@"\\?\{0}", expandedValue);
                    filePath.LongPath = new Regex(tempVal.Replace("\\", "\\\\"),
                                                  RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.Compiled);

                    IgnoreFiles.Add(filePath);
                }
            }

            IgnoreRegKeys = FileUtility.Inst.GetFileLines(GetResourcePath(IGNOREREGISTRYKEYS_FILE));
        }