コード例 #1
0
ファイル: Transaction.cs プロジェクト: NTDLS/LeafSQL
        public void RecordPathDelete(string diskPath)
        {
            try
            {
                lock (ReversibleActions)
                {
                    if (IsFileAlreadyRecorded(diskPath))
                    {
                        return;
                    }

                    string backupPath = Path.Combine(TransactionPath, Guid.NewGuid().ToString());
                    Directory.CreateDirectory(backupPath);
                    Helpers.CopyDirectory(diskPath, backupPath);

                    var reversibleAction = new ReversibleAction
                    {
                        Action       = ActionType.DirectoryDelete,
                        OriginalPath = diskPath.ToLower(),
                        BackupPath   = backupPath,
                        Sequence     = ReversibleActions.Count
                    };

                    ReversibleActions.Add(reversibleAction);
                    this.transactionLogHandle.WriteLine(JsonConvert.SerializeObject(reversibleAction));
                }
            }
            catch (Exception ex)
            {
                core.Log.Write(String.Format("Failed to record file deletion for process {0}.", this.ProcessId), ex);
                throw;
            }
        }
コード例 #2
0
ファイル: Transaction.cs プロジェクト: NTDLS/LeafSQL
        public void RecordFileAlter(string filePath)
        {
            try
            {
                lock (ReversibleActions)
                {
                    if (IsFileAlreadyRecorded(filePath))
                    {
                        return;
                    }

                    string backupPath = Path.Combine(TransactionPath, Guid.NewGuid() + ".bak");
                    File.Copy(filePath, backupPath);

                    var reversibleAction = new ReversibleAction
                    {
                        Action       = ActionType.FileAlter,
                        OriginalPath = filePath.ToLower(),
                        BackupPath   = backupPath,
                        Sequence     = ReversibleActions.Count
                    };

                    ReversibleActions.Add(reversibleAction);
                    this.transactionLogHandle.WriteLine(JsonConvert.SerializeObject(reversibleAction));
                }
            }
            catch (Exception ex)
            {
                core.Log.Write(String.Format("Failed to record file alteration for process {0}.", this.ProcessId), ex);
                throw;
            }
        }
コード例 #3
0
ファイル: Transaction.cs プロジェクト: NTDLS/LeafSQL
        public void RecordDirectoryCreate(string path)
        {
            try
            {
                lock (ReversibleActions)
                {
                    if (IsFileAlreadyRecorded(path))
                    {
                        return;
                    }

                    var reversibleAction = new ReversibleAction
                    {
                        Action       = ActionType.DirectoryCreate,
                        OriginalPath = path.ToLower(),
                        Sequence     = ReversibleActions.Count
                    };

                    ReversibleActions.Add(reversibleAction);
                    this.transactionLogHandle.WriteLine(JsonConvert.SerializeObject(reversibleAction));
                }
            }
            catch (Exception ex)
            {
                core.Log.Write(String.Format("Failed to record file creation for processId {0}.", this.ProcessId), ex);
                throw;
            }
        }