/// <summary> /// Gets a file in the specified branding folder /// </summary> /// <param name="brandingNameOrFolderPath"> Normally, the branding is just a name, which we look up in the official branding folder // but unit tests can instead provide a path to the folder. /// </param> /// <param name="fileName"></param> /// <returns></returns> public static string GetOptionalBrandingFile(string brandingNameOrFolderPath, string fileName) { if (Path.IsPathRooted(brandingNameOrFolderPath)) //if it looks like a path { var path = Path.Combine(brandingNameOrFolderPath, fileName); if (RobustFile.Exists(path)) { return(path); } return(null); } if (Path.IsPathRooted(fileName) && RobustFile.Exists(fileName)) // also just for unit tests { return(fileName); } return(BloomFileLocator.GetBrowserFile(true, "branding", brandingNameOrFolderPath, fileName)); }
/// <summary> /// This can be used to find the best localized file when there is only one file with the given name, /// and the file is part of the files distributed with Bloom (i.e., not something in a downloaded template). /// </summary> public static string GetBestLocalizableFileDistributedWithApplication(bool existenceOfEnglishVersionIsOptional, params string[] partsOfEnglishFilePath) { // at this time, FileLocator does not have a way for the app to actually tell it where to find things distributed // with the application... var englishPath = FileLocator.GetFileDistributedWithApplication(true, partsOfEnglishFilePath); // ... so if it doesn't find it, we have to keep looking if (string.IsNullOrWhiteSpace(englishPath)) { //this one will throw if we still can't find it and existenceOfEnglishVersionIsOptional is false englishPath = BloomFileLocator.GetBrowserFile(existenceOfEnglishVersionIsOptional, partsOfEnglishFilePath); } if (!RobustFile.Exists(englishPath)) { return(englishPath); // just return whatever the original GetFileDistributedWithApplication gave. "", null, whatever it is. } return(BloomFileLocator.GetBestLocalizedFile(englishPath)); }
public string GetBrandingFile(Boolean optional, string fileName) { return(BloomFileLocator.GetBrowserFile(optional, "branding", _collectionSettings.GetBrandingFolderName(), fileName)); }