/// <summary>
        /// 無視対象ファイルをリストアップする。途中で処理がキャンセルされた場合はnullを返す
        /// </summary>
        protected virtual List <string> SearchIgnoredFiles(IgnoreSetting setting, CancellationToken cToken)
        {
            var paths = new List <string>();

            try
            {
                Util.ApplyAllFiles(_app.Logger, TxtBaseDirPath.Text, (path) =>
                {
                    var fileAttrs   = File.GetAttributes(path);
                    var isDirectory = fileAttrs.HasFlag(System.IO.FileAttributes.Directory);
                    if (setting.IsMatch(path, isDirectory))
                    {
                        paths.Add(path);
                    }

                    cToken.ThrowIfCancellationRequested();
                });
            }
            catch (OperationCanceledException)
            {
                return(null);
            }

            return(paths);
        }
示例#2
0
        public void BasicTest()
        {
            foreach (var dataSet in _dataSets)
            {
                foreach (var testPattern in dataSet.TestPatterns)
                {
                    var setting = new IgnoreSetting(dataSet.BaseDirPath);
                    setting.AddPattern(testPattern.Pattern);

                    if (testPattern.ShouldBeMatched)
                    {
                        Assert.IsTrue(setting.IsMatch(dataSet.TargetPath, dataSet.TargetIsDirectory));
                    }
                    else
                    {
                        Assert.IsFalse(setting.IsMatch(dataSet.TargetPath, dataSet.TargetIsDirectory));
                    }
                }
            }
        }