Пример #1
0
 public MpqArchive(
     string path,
     int defaultSearchPriority = 1,
     MpqLoadOptions options = MpqLoadOptions.OpenEncrypted | MpqLoadOptions.OpenReadOnly)
     : this(CreateFileStreamFromPathAndOptions(path, options), defaultSearchPriority, options)
 {
 }
Пример #2
0
 public MpqArchive(
     string path,
     int defaultSearchPriority = 1,
     MpqLoadOptions options    = MpqLoadOptions.OpenEncrypted | MpqLoadOptions.OpenReadOnly)
     : this(CreateFileStreamFromPathAndOptions(path, options), defaultSearchPriority, options)
 {
 }
Пример #3
0
        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();
        }
Пример #4
0
 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);
     }
 }
Пример #5
0
 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));
     }
 }
Пример #6
0
        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();
        }