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