using System.IO; using System.Linq; using Chernobyl.Collections.Generic.Event; namespace Chernobyl.IO { /// /// This class is used to search a set of search paths or directory paths /// for a specific file. When found, the FileSearchStream can be read from /// just like a FileStream. /// public class FileSearchStream : FileStream { /// /// Constructor. /// /// The services object that contains a /// SearchPath instance. This SearchPath will be used to find the /// specified file. /// The file path to the file that is contained /// within at least one of the search paths specified by the /// in the /// instance. /// How the operating system should open the file. public FileSearchStream(IEventCollection services, string file, FileMode fileMode) : this(services.OfType().First(), file, fileMode) { } /// /// Constructor. /// /// The services object that contains a /// SearchPath instance. This SearchPath will be used to find the /// specified file. /// The file path to the file that is contained /// within at least one of the search paths specified by the /// in the /// instance. /// How the operating system should open the file. /// How the file will be accessed public FileSearchStream(IEventCollection services, string file, FileMode fileMode, FileAccess fileAccess) : this(services.OfType().First(), file, fileMode, fileAccess) { } /// /// Constructor. /// /// The search path instance that contains the /// search paths that should be searched for the specified file. /// The file path to the file that is contained /// within at least one of the search paths specified by /// . /// How the operating system should open the file. public FileSearchStream(ISearchPaths searchPaths, string file, FileMode fileMode) : base(searchPaths.FilePaths(file).First(), fileMode) { } /// /// Constructor. /// /// The search path instance that contains the /// search paths that should be searched for the specified file. /// The file path to the file that is contained /// within at least one of the search paths specified by /// . /// How the operating system should open the file. /// How the file will be accessed public FileSearchStream(ISearchPaths searchPaths, string file, FileMode fileMode, FileAccess fileAccess) : base(searchPaths.FilePaths(file).First(), fileMode, fileAccess) { } } }