예제 #1
0
        /// <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);
                }
            }
        }
예제 #2
0
 public override void CopyTree(SyncDirectoryInfo from, SyncFileDirName toFullPath)
 {
     DoCopyTree(from, toFullPath);
 }
예제 #3
0
 public abstract void CopyTree(SyncDirectoryInfo from, SyncFileDirName toFullPath);
예제 #4
0
 public override void Copy(SyncFileInfo from, SyncFileDirName toFullName)
 {
     Actioner.Copy(from.FullName, toFullName.FullName);
 }
예제 #5
0
 public abstract void Copy(SyncFileInfo from, SyncFileDirName toFullName);
예제 #6
0
 public override void CopyTree(SyncDirectoryInfo from, SyncFileDirName toFullPath)
 {
     Logger.WriteLine("CopyTree '{0}' -> '{1}'", from, toFullPath);
 }
예제 #7
0
 /// <summary>
 /// External file doesn't exist so copy.
 /// </summary>
 public override void ProcessFile(SyncFileInfo localFile, SyncFileDirName externalFile)
 {
     mover.Copy(from: localFile, toFullName: externalFile);
 }
예제 #8
0
 public override void Copy(SyncFileInfo from, SyncFileDirName toFullName)
 {
     Logger.WriteLine("Copy '{0}' -> '{1}'", from, toFullName);
 }
예제 #9
0
 /// <summary>
 /// localFile doesn't exist, so deletes external file.
 /// </summary>
 public override void ProcessFile(SyncFileDirName localFile, SyncFileInfo externalFile)
 {
     mover.Remove(externalFile);
 }
예제 #10
0
 /// <summary>
 /// Take decision about sub-directory when external exists but local does not.
 /// </summary>
 public abstract void ProcessDir(SyncFileDirName localDir, SyncDirectoryInfo externalDir);
예제 #11
0
 /// <summary>
 /// Take decision in case only externalFile exists
 /// </summary>
 public abstract void ProcessFile(SyncFileDirName localFile, SyncFileInfo externalFile);
예제 #12
0
 /// <summary>
 /// Local directory does not exist, so copy
 /// </summary>
 public override void ProcessDir(SyncFileDirName localDir, SyncDirectoryInfo externalDir)
 {
     mover.CopyTree(from: externalDir, toFullPath: localDir);
 }
예제 #13
0
 /// <summary>
 /// Local directory exists but external does not, so delete local
 /// </summary>
 public override void ProcessDir(SyncDirectoryInfo localDir, SyncFileDirName externalDir)
 {
     mover.DeleteTree(localDir);
 }