public static System.DateTime GetBackupCreationTime(string backupName) { if (backupName.StartsWith("~")) { GHistoryEntry entry = GetHistoryEntry(backupName); if (entry != null) { return(entry.CreationTime); } else { return(System.DateTime.MaxValue); } } else { string folder = GetFileDirectory(backupName); if (Directory.Exists(folder)) { return(Directory.GetCreationTime(folder)); } else { return(System.DateTime.MaxValue); } } }
private static GHistoryEntry EnsureHistoryEntryExists(string backupName) { GHistoryEntry entry = GetHistoryEntry(backupName); if (entry == null) { entry = new GHistoryEntry(backupName); GBackupData.Instance.HistoryEntries.Add(entry); } return(entry); }
public static bool HistoryContainsDataForTerrain(string backupName, string terrainId) { GHistoryEntry entry = GetHistoryEntry(backupName); if (entry == null) { return(false); } GHistoryBuffer buffer = entry.Buffers.Find(b => b.Name.Contains(terrainId)); return(buffer != null); }
public static string Create(string backupName, string fileNameNoExt, byte[] data) { if (backupName.StartsWith("~")) { GHistoryEntry entry = EnsureHistoryEntryExists(backupName); GHistoryBuffer buffer = new GHistoryBuffer(fileNameNoExt, data); entry.Buffers.Add(buffer); return(string.Empty); } else { GUtilities.EnsureDirectoryExists(Path.Combine(GetRootDirectory(), backupName)); string filePath = GetFilePath(backupName, fileNameNoExt); File.WriteAllBytes(filePath, data); return(filePath); } }
public static bool Exist(string backupName, string fileNameNoExt) { if (backupName.StartsWith("~")) { GHistoryEntry entry = GetHistoryEntry(backupName); if (entry == null) { return(false); } GHistoryBuffer buffer = entry.Buffers.Find(b => b.Name.Equals(fileNameNoExt)); return(buffer != null); } else { string filePath = GetFilePath(backupName, fileNameNoExt); return(File.Exists(filePath)); } }
public static void SetBackupCreationTime(string backupName, System.DateTime time) { if (backupName.StartsWith("~")) { GHistoryEntry entry = GetHistoryEntry(backupName); if (entry != null) { entry.CreationTime = time; } } else { string folder = GetFileDirectory(backupName); if (Directory.Exists(folder)) { Directory.SetCreationTime(folder, time); } } }
public static byte[] ReadAllBytes(string backupName, string fileNameNoExtension) { if (Exist(backupName, fileNameNoExtension)) { if (backupName.StartsWith("~")) { GHistoryEntry entry = GBackupData.Instance.HistoryEntries.Find(e => e.Name.Equals(backupName)); GHistoryBuffer buffer = entry.Buffers.Find(b => b.Name.Equals(fileNameNoExtension)); return(buffer.Bytes); } else { return(File.ReadAllBytes(GetFilePath(backupName, fileNameNoExtension))); } } else { return(null); } }