示例#1
0
        public static void SyncFolders(string src, string dst, StringCollection includeGlobs, StringCollection excludeGlobs)
        {
            Glob[] includes;
            Glob[] excludes;

            includes = GlobMatcher.PrepareGlobs(includeGlobs);
            excludes = GlobMatcher.PrepareGlobs(excludeGlobs);

            SimpleFolderSync.SyncFolders(src, dst, includes, excludes);
        }
示例#2
0
        public static bool IsIncluded(StringCollection files, StringCollection includeGlobs)
        {
            bool result;

            Glob[] includes;

            result   = false;
            includes = GlobMatcher.PrepareGlobs(includeGlobs);

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

            return(result);
        }
示例#3
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);
                    }
                }
            }
        }
示例#4
0
 public static bool IsIncluded(string file, Glob[] globs)
 {
     return(globs.Length == 0 || GlobMatcher.IsMatch(file, globs));
 }
示例#5
0
 public static bool IsExcluded(string file, Glob[] globs)
 {
     return(globs.Length != 0 && GlobMatcher.IsMatch(file, globs));
 }