public MpqArchive( string path, int defaultSearchPriority = 1, MpqLoadOptions options = MpqLoadOptions.OpenEncrypted | MpqLoadOptions.OpenReadOnly) : this(CreateFileStreamFromPathAndOptions(path, options), defaultSearchPriority, options) { }
public MpqArchive( Stream source, int defaultSearchPriority = 1, MpqLoadOptions options = MpqLoadOptions.OpenEncrypted | MpqLoadOptions.OpenReadOnly) { if (source == null) { throw new ArgumentNullException("source"); } if (!source.CanRead) { throw new ArgumentException("Source stream must be readable.", "source"); } if (!source.CanSeek) { throw new ArgumentException("Source stream must be seekable.", "source"); } if (!options.HasFlag(MpqLoadOptions.OpenReadOnly)) { throw new NotSupportedException("Writable MPQ archives are not yet supported."); } _strm = source; _searchPriority = defaultSearchPriority; _options = options; Initialize(); }
private static Stream CreateFileStreamFromPathAndOptions(string path, MpqLoadOptions options) { if (options.HasFlag(MpqLoadOptions.OpenReadOnly)) { return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); } else { return new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } }
private static Stream CreateFileStreamFromPathAndOptions(string path, MpqLoadOptions options) { if (options.HasFlag(MpqLoadOptions.OpenReadOnly)) { return(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)); } else { return(new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)); } }
public MpqArchive( Stream source, int defaultSearchPriority = 1, MpqLoadOptions options = MpqLoadOptions.OpenEncrypted | MpqLoadOptions.OpenReadOnly) { if (source == null) throw new ArgumentNullException("source"); if (!source.CanRead) throw new ArgumentException("Source stream must be readable.", "source"); if (!source.CanSeek) throw new ArgumentException("Source stream must be seekable.", "source"); if (!options.HasFlag(MpqLoadOptions.OpenReadOnly)) throw new NotSupportedException("Writable MPQ archives are not yet supported."); _strm = source; _searchPriority = defaultSearchPriority; _options = options; Initialize(); }