예제 #1
0
        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);
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
 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));
     }
 }
예제 #4
0
 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);
     }
 }