Ejemplo n.º 1
0
 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);
         }
     }
 }
Ejemplo n.º 2
0
        private static GHistoryEntry EnsureHistoryEntryExists(string backupName)
        {
            GHistoryEntry entry = GetHistoryEntry(backupName);

            if (entry == null)
            {
                entry = new GHistoryEntry(backupName);
                GBackupData.Instance.HistoryEntries.Add(entry);
            }
            return(entry);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
     }
 }
Ejemplo n.º 5
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));
     }
 }
Ejemplo n.º 6
0
 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);
         }
     }
 }
Ejemplo n.º 7
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);
     }
 }