/// <summary> /// Writes the file represented by the given byte array to the given path. /// </summary> /// <remarks> /// This method writes the given data as a file at the given path, if it is owned /// by the mod being upgraded. If the specified data file is not owned by the mod /// being upgraded, the file is instead written to the overwrites directory. /// /// If the file was not previously installed by the mod, then the normal install rules apply, /// including confirming overwrite if applicable. /// </remarks> /// <param name="p_strPath">The path where the file is to be created.</param> /// <param name="p_bteData">The data that is to make up the file.</param> /// <param name="p_booSecondaryInstallPath">Whether to use the secondary install path.</param> /// <returns><c>true</c> if the file was written; <c>false</c> if the user chose /// not to overwrite an existing file.</returns> /// <exception cref="IllegalFilePathException">Thrown if <paramref name="p_strPath"/> is /// not safe.</exception> public override bool GenerateDataFile(string p_strPath, byte[] p_bteData, bool p_booSecondaryInstallPath) { DataFileUtility.AssertFilePathIsSafe(p_strPath); string strInstallFilePath = Path.Combine(GameModeInfo.InstallationPath, p_strPath); IList <IMod> lstInstallers = InstallLog.GetFileInstallers(p_strPath); if (lstInstallers.Contains(Mod, ModComparer.Filename)) { string strWritePath = null; if (!ModComparer.Filename.Equals(lstInstallers[lstInstallers.Count - 1], Mod)) { string strDirectory = Path.GetDirectoryName(p_strPath); string strBackupPath = Path.Combine(GameModeInfo.OverwriteDirectory, strDirectory); string strOldModKey = InstallLog.GetModKey(Mod); string strFile = strOldModKey + "_" + Path.GetFileName(p_strPath); strWritePath = Path.Combine(strBackupPath, strFile); } else { strWritePath = strInstallFilePath; } TransactionalFileManager.WriteAllBytes(strWritePath, p_bteData); OriginallyInstalledFiles.Remove(p_strPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar)); return(true); } return(base.GenerateDataFile(p_strPath, p_bteData, false)); }