/// <summary> /// If the collection has no reader tools at all, or if ones that came with the program are newer, /// copy the ones that came with the program. /// This is language-dependent, we'll typically only overwrite settings for an English collection. /// </summary> /// <param name="settings"></param> public static void CopyRelevantNewReaderSettings(CollectionSettings settings) { var readerToolsPath = GetReaderToolsSettingsFilePath(settings); var bloomFolder = ProjectContext.GetBloomAppDataFolder(); var newReaderTools = Path.Combine(bloomFolder, Path.GetFileName(readerToolsPath)); if (!RobustFile.Exists(newReaderTools)) { return; } if (RobustFile.Exists(readerToolsPath) && RobustFile.GetLastWriteTime(readerToolsPath) > RobustFile.GetLastWriteTime(newReaderTools)) { return; // don't overwrite newer existing settings? } RobustFile.Copy(newReaderTools, readerToolsPath, true); }
/// <summary> /// If the collection has no reader tools at all, or if ones that came with the program are newer, /// copy the ones that came with the program. /// This is language-dependent, we'll typically only overwrite settings for an English collection. /// Or, if the language came as a bloompack, we may copy updated settings for a newer bloompack. /// Basically this copies the same set of files as CopyReaderToolsSettingsToWhereTheyBelong creates /// into the book's own folder. /// </summary> public static void CopyRelevantNewReaderSettings(CollectionSettings settings) { var readerToolsPath = GetReaderToolsSettingsFilePath(settings); var bloomFolder = ProjectContext.GetBloomAppDataFolder(); var readerSettingsFileName = Path.GetFileName(readerToolsPath); var newReaderTools = Path.Combine(bloomFolder, readerSettingsFileName); if (!RobustFile.Exists(newReaderTools)) { return; } if (RobustFile.Exists(readerToolsPath) && RobustFile.GetLastWriteTime(readerToolsPath) > RobustFile.GetLastWriteTime(newReaderTools)) { return; // don't overwrite newer existing settings? } RobustFile.Copy(newReaderTools, readerToolsPath, true); // If the settings file is being updated, we should update the corresponding allowed words, if any. var langCode = Path.GetFileNameWithoutExtension(readerSettingsFileName.Substring(ReaderToolsSettingsPrefix.Length)); CopyAllowedWords(Path.Combine(bloomFolder, AllowedWordsFolderName + "-" + langCode), Path.Combine(Path.GetDirectoryName(readerToolsPath), AllowedWordsFolderName)); }