示例#1
0
        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);
            }
        }
示例#2
0
 private void AfterTagModified(string fileName, byte[] after)
 {
     UndoFile.Write(new SerializedCommand(
                        GetType(),
                        SerializedCommand.UndoRedo.Do,
                        "after",
                        new string[] { fileName, Convert.ToBase64String(after) }));
 }
示例#3
0
 private void BeforTagModified(string fileName, byte[] before)
 {
     UndoFile.Write(new SerializedCommand(
                        GetType(),
                        SerializedCommand.UndoRedo.Undo,
                        "before",
                        new string[] { fileName, Convert.ToBase64String(before) }));
 }
示例#4
0
        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);
            }
        }