コード例 #1
0
ファイル: GlobMatcher.cs プロジェクト: cyotek/SvnGitMigrate
        public static bool IsExcluded(StringCollection files, StringCollection excludeGlobs)
        {
            bool result;

            Glob[] excludes;

            result   = false;
            excludes = GlobMatcher.PrepareGlobs(excludeGlobs);

            for (int i = 0; i < files.Count; i++)
            {
                if (GlobMatcher.IsExcluded(files[i], excludes))
                {
                    result = true;
                    break;
                }
            }

            return(result);
        }
コード例 #2
0
        private static void CopyNewOrChangedFiles(string src, string dst, Glob[] includes, Glob[] excludes)
        {
            foreach (string srcFile in Directory.EnumerateFiles(src))
            {
                if (GlobMatcher.IsIncluded(srcFile, includes) && !GlobMatcher.IsExcluded(srcFile, excludes))
                {
                    string   dstFile;
                    FileInfo dstInfo;
                    FileInfo srcInfo;

                    dstFile = Path.Combine(dst, Path.GetFileName(srcFile));
                    dstInfo = new FileInfo(dstFile);
                    srcInfo = new FileInfo(srcFile);

                    if (!dstInfo.Exists || dstInfo.Length != srcInfo.Length || !FileCompare.AreSame(srcFile, dstFile))
                    {
                        Directory.CreateDirectory(dst);
                        File.Copy(srcFile, dstFile, true);
                    }
                }
            }
        }