public static string BackupFile(string file) { bool flag = false; string backupFile = VmcStudioUtil.GetBackupFile(file); if (!File.Exists(backupFile)) { Trace.TraceInformation("No backup of {0} exists, creating {1}.", (object)file, (object)backupFile); flag = true; } else { string fileVersion1 = VmcStudioUtil.GetFileVersion(backupFile); string fileVersion2 = VmcStudioUtil.GetFileVersion(file); if (fileVersion1 != fileVersion2) { Trace.TraceInformation("Version of {0} has changed ({1} to {2}), refreshing backup file {3}.", (object)file, (object)fileVersion1, (object)fileVersion2, (object)backupFile); VmcStudioUtil.TakeOwnership(backupFile); flag = true; } } if (flag) { Directory.CreateDirectory(Path.GetDirectoryName(backupFile)); File.Copy(file, backupFile, true); } return(backupFile); }
public static bool PrepareForSave(MediaCenterLibraryCache cache) { bool flag = true; foreach (string path2 in cache.LoadedFiles) { string str = Path.Combine(cache.SearchPath, path2); if (File.Exists(str)) { VmcStudioUtil.BackupFile(str); if (!VmcStudioUtil.TakeOwnership(str)) { throw new VmcStudioException(string.Format("Could not take ownership of {0}.", (object)str)); } } else { Trace.TraceWarning("File not found: {0}", new object[1] { (object)str }); } } if (!VmcStudioUtil.EnsureMediaCenterClosed(true)) { flag = false; } return(flag); }