Esempio n. 1
0
        public virtual void Backup()
        {
            if (!OperationBackupGuard.ShouldBackup(_file.TxFileSystem.Journal, this.OperationType))
            {
                return;
            }

            if (!_file.TxFileSystem.FileSystem.File.Exists(this.BackupPath))
            {
                _file.TxFileSystem.FileSystem.File.Copy(this.Path, this.BackupPath);
            }
        }
Esempio n. 2
0
        public virtual void Delete()
        {
            if (!OperationBackupGuard.ShouldRestore(_directory.TxFileSystem.Journal, this.OperationType))
            {
                return;
            }

            if (_directory.TxFileSystem.FileSystem.Directory.Exists(this.BackupPath))
            {
                _directory.TxFileSystem.FileSystem.Directory.Delete(this.BackupPath, recursive: true);
            }
        }
Esempio n. 3
0
        public virtual void Backup()
        {
            if (!OperationBackupGuard.ShouldBackup(_directory.TxFileSystem.Journal, this.OperationType))
            {
                return;
            }

            if (_directory.TxFileSystem.FileSystem.Directory.Exists(this.Path))
            {
                _directory.CopyRecursive(this.Path, this.BackupPath);
            }

            this.IsBackedUp = true;
        }
        public virtual void Backup()
        {
            if (!OperationBackupGuard.ShouldBackup(_fileStream.TxFileSystem.Journal, this.OperationType))
            {
                return;
            }

            var oldPosition = _stream.Position;

            var data = new byte[_stream.Length];

            _stream.Seek(0, SeekOrigin.Begin);
            _stream.Read(data, 0, (int)_stream.Length);

            var backupFileStream = _fileStream.TxFileSystem.FileSystem.File.Create(this.BackupPath);

            backupFileStream.Write(data, 0, data.Length);
            backupFileStream.Flush();
            backupFileStream.Close();

            _stream.Seek(oldPosition, SeekOrigin.Begin);
        }