예제 #1
0
        /// <summary>
        /// Create new OMOD instance from File.
        /// </summary>
        /// <param name="path"></param>
        /// <exception cref="ArgumentException"></exception>
        public OMOD(string path)
        {
            if (!File.Exists(path))
            {
                throw new ArgumentException($"File at {path} does not exist!", nameof(path));
            }

            _zipArchive = ZipFile.Open(path, ZipArchiveMode.Read, Encoding.UTF8);

            OMODArchiveValidation.ValidateArchive(_zipArchive);

            using var configStream = GetEntryFileStream(OMODEntryFileType.Config);
            Config = OMODConfig.ParseConfig(configStream);
        }
예제 #2
0
        /// <summary>
        /// Create new OMOD instance from Stream.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="leaveOpen"></param>
        /// <exception cref="ArgumentException"></exception>
        public OMOD(Stream stream, bool leaveOpen = false)
        {
            if (!stream.CanRead)
            {
                throw new ArgumentException("Stream does not support reading!", nameof(stream));
            }
            if (!stream.CanSeek)
            {
                throw new ArgumentException("Stream does not support seeking!", nameof(stream));
            }

            _zipArchive = new ZipArchive(stream, ZipArchiveMode.Read, leaveOpen, Encoding.UTF8);

            OMODArchiveValidation.ValidateArchive(_zipArchive);

            using var configStream = GetEntryFileStream(OMODEntryFileType.Config);
            Config = OMODConfig.ParseConfig(configStream);
        }