Used to load and save data related to a backup.
コード例 #1
0
ファイル: Backup.cs プロジェクト: Tokeiburu/RagnarokSDE
		public Backup(string backup) {
			if (backup == null) throw new ArgumentNullException("backup");

			BackupDate = backup;
			Entry = BackupEngine.Instance.Grf.FileTable[GrfPath.Combine(BackupDate, BackupEngine.InfoName)];
			Info = new BackupInfo(new ReadonlyConfigAsker(Entry.GetDecompressedData()));
		}
コード例 #2
0
ファイル: BackupEngine.cs プロジェクト: Tokeiburu/RagnarokSDE
		public void Start(string dbPath) {
			if (!SdeAppConfiguration.BackupsManagerState || _isCrashed) return;
			if (dbPath == null) throw new ArgumentNullException("dbPath");

			_currentId++;

			_validateOpened();

			BackupInfo info = new BackupInfo(new TextConfigAsker(new byte[] {}));
			info.DestinationPath = Path.GetDirectoryName(dbPath);

			if (!_paths.ContainsKey(_currentId)) {
				_paths[_currentId] = _getGrfPath();
			}

			_grf.Commands.AddFileAbsolute(GrfPath.Combine(_paths[_currentId], InfoName), info.GetData());

			List<string> paths = GetBackupFiles().OrderBy(long.Parse).ToList();

			while (paths.Count > MaximumNumberOfBackups) {
				RemoveBackupDelayed(paths[0]);
				paths.RemoveAt(0);
			}

			_isStarted = true;
		}
コード例 #3
0
        public void Restore(string backup)
        {
            if (backup == null)
            {
                throw new ArgumentNullException("backup");
            }

            _validateOpened();

            BackupInfo info = new BackupInfo(new ReadonlyConfigAsker(_grf.FileTable[GrfPath.Combine(backup, InfoName)].GetDecompressedData()));

            if (!Directory.Exists(info.DestinationPath))
            {
                Directory.CreateDirectory(info.DestinationPath);
            }

            foreach (FileEntry entry in _grf.FileTable.EntriesInDirectory(backup, SearchOption.AllDirectories))
            {
                if (entry.RelativePath.EndsWith(InfoName))
                {
                    continue;
                }

                entry.ExtractFromAbsolute(GrfPath.Combine(info.DestinationPath, entry.RelativePath.ReplaceFirst(backup + "\\", "")));
            }

            _grf.Close();
        }
コード例 #4
0
        public void Start(string dbPath)
        {
            if (!SdeAppConfiguration.BackupsManagerState || _isCrashed)
            {
                return;
            }
            if (dbPath == null)
            {
                throw new ArgumentNullException("dbPath");
            }

            _currentId++;

            _validateOpened();

            BackupInfo info = new BackupInfo(new TextConfigAsker(new byte[] {}));

            info.DestinationPath = Path.GetDirectoryName(dbPath);

            if (!_paths.ContainsKey(_currentId))
            {
                _paths[_currentId] = _getGrfPath();
            }

            _grf.Commands.AddFileAbsolute(GrfPath.Combine(_paths[_currentId], InfoName), info.GetData());

            List <string> paths = GetBackupFiles().OrderBy(long.Parse).ToList();

            while (paths.Count > MaximumNumberOfBackups)
            {
                RemoveBackupDelayed(paths[0]);
                paths.RemoveAt(0);
            }

            _isStarted = true;
        }
コード例 #5
0
ファイル: BackupEngine.cs プロジェクト: Tokeiburu/RagnarokSDE
		public void Restore(string backup) {
			if (backup == null) throw new ArgumentNullException("backup");

			_validateOpened();

			BackupInfo info = new BackupInfo(new ReadonlyConfigAsker(_grf.FileTable[GrfPath.Combine(backup, InfoName)].GetDecompressedData()));

			if (!Directory.Exists(info.DestinationPath)) {
				Directory.CreateDirectory(info.DestinationPath);
			}

			foreach (FileEntry entry in _grf.FileTable.EntriesInDirectory(backup, SearchOption.AllDirectories)) {
				if (entry.RelativePath.EndsWith(InfoName))
					continue;

				entry.ExtractFromAbsolute(GrfPath.Combine(info.DestinationPath, entry.RelativePath.ReplaceFirst(backup + "\\", "")));
			}
			
			_grf.Close();
		}