private void MoveToRecycleBin(string id) { SerializedCommand cmd; if (VirtualDrive.ExistsDirectory(id)) { cmd = CreateDeleteCommand(new DirectoryInfo(id)); } else if (VirtualDrive.ExistsFile(id)) { cmd = CreateDeleteCommand(new FileInfo(id)); } else { throw new Exception("\"" + id + "\" does not exist!"); } ProcessCommand(cmd); if (!Object.ReferenceEquals(UndoFile, null)) { UndoFile.Write(CreateUndoCommand(cmd)); UndoFile.Write(cmd); } }
private void AfterTagModified(string fileName, byte[] after) { UndoFile.Write(new SerializedCommand( GetType(), SerializedCommand.UndoRedo.Do, "after", new string[] { fileName, Convert.ToBase64String(after) })); }
private void BeforTagModified(string fileName, byte[] before) { UndoFile.Write(new SerializedCommand( GetType(), SerializedCommand.UndoRedo.Undo, "before", new string[] { fileName, Convert.ToBase64String(before) })); }
public virtual void Process(object obj) { SerializedCommand cmd = CreateDoCommand(obj); if (Operation == FileOperation.Copy || Operation == FileOperation.Move) { if (String.IsNullOrEmpty(NewName)) { throw new Exception(Operation.ToString() + " invalid filename: \"" + NewName + "\""); } string src = cmd.Data[0]; string dst = cmd.Data[1]; if (src.Equals(dst)) { return; } if (AlreadyExists(src, dst)) { if (Conflicts == ConflictSolving.Skip) { Logger.WriteLine(Tokens.Warning, Operation.ToString() + " already exists: \"" + dst + "\""); return; } else if (Conflicts == ConflictSolving.Overwrite) { MoveToRecycleBin(dst); } } } ProcessCommand(cmd); if (!Object.ReferenceEquals(UndoFile, null)) { UndoFile.Write(CreateUndoCommand(cmd)); UndoFile.Write(cmd); } }