/// <summary> /// Actually copy a tree; to be called by derived class /// </summary> protected void DoCopyTree(SyncDirectoryInfo from, SyncFileDirName toFullPath) { Actioner.CreateDirectory(toFullPath.FullName); var toCopy = new Stack <string>(); toCopy.Push(""); while (toCopy.Count() > 0) { string path = toCopy.Pop(); string fromPath = Path.Combine(from.FullName, path); string toPath = Path.Combine(toFullPath.FullName, path); foreach (var fileName in Directory.EnumerateFiles(fromPath)) { // fileName contains full path, so need to extract filename! string name = Path.GetFileName(fileName); Actioner.Copy(Path.Combine(fromPath, name), Path.Combine(toPath, name)); } foreach (var dirName in Directory.EnumerateDirectories(fromPath)) { var fullDirName = Path.Combine(path, Path.GetFileName(dirName)); Actioner.CreateDirectory(Path.Combine(toPath, fullDirName)); toCopy.Push(fullDirName); } } }
public override void CopyTree(SyncDirectoryInfo from, SyncFileDirName toFullPath) { DoCopyTree(from, toFullPath); }
public abstract void CopyTree(SyncDirectoryInfo from, SyncFileDirName toFullPath);
public override void Copy(SyncFileInfo from, SyncFileDirName toFullName) { Actioner.Copy(from.FullName, toFullName.FullName); }
public abstract void Copy(SyncFileInfo from, SyncFileDirName toFullName);
public override void CopyTree(SyncDirectoryInfo from, SyncFileDirName toFullPath) { Logger.WriteLine("CopyTree '{0}' -> '{1}'", from, toFullPath); }
/// <summary> /// External file doesn't exist so copy. /// </summary> public override void ProcessFile(SyncFileInfo localFile, SyncFileDirName externalFile) { mover.Copy(from: localFile, toFullName: externalFile); }
public override void Copy(SyncFileInfo from, SyncFileDirName toFullName) { Logger.WriteLine("Copy '{0}' -> '{1}'", from, toFullName); }
/// <summary> /// localFile doesn't exist, so deletes external file. /// </summary> public override void ProcessFile(SyncFileDirName localFile, SyncFileInfo externalFile) { mover.Remove(externalFile); }
/// <summary> /// Take decision about sub-directory when external exists but local does not. /// </summary> public abstract void ProcessDir(SyncFileDirName localDir, SyncDirectoryInfo externalDir);
/// <summary> /// Take decision in case only externalFile exists /// </summary> public abstract void ProcessFile(SyncFileDirName localFile, SyncFileInfo externalFile);
/// <summary> /// Local directory does not exist, so copy /// </summary> public override void ProcessDir(SyncFileDirName localDir, SyncDirectoryInfo externalDir) { mover.CopyTree(from: externalDir, toFullPath: localDir); }
/// <summary> /// Local directory exists but external does not, so delete local /// </summary> public override void ProcessDir(SyncDirectoryInfo localDir, SyncFileDirName externalDir) { mover.DeleteTree(localDir); }