Пример #1
0
        public bool HasLump(BinaryStateLump lump)
        {
            string   name = BinaryStateFileNames.GetReadName(lump);
            ZipEntry e;

            return(_entriesbyname.TryGetValue(name, out e));
        }
Пример #2
0
        public void PutLump(BinaryStateLump lump, Action <Stream> callback)
        {
            var name = BinaryStateFileNames.Get(lump);
            var e    = new ZipEntry(name);

            if (Global.Config.SaveStateCompressionLevelNormal == 0)
            {
                e.CompressionMethod = CompressionMethod.Stored;
            }
            else
            {
                e.CompressionMethod = CompressionMethod.Deflated;
            }
            _zip.PutNextEntry(e);
            callback(_zip);
            _zip.CloseEntry();
        }
Пример #3
0
        /// <summary>
        /// Gets a lump
        /// </summary>
        /// <param name="lump">lump to retriever</param>
        /// <param name="abort">true to throw exception on failure</param>
        /// <param name="callback">function to call with the desired stream</param>
        /// <returns>true if callback was called and stream was loaded</returns>
        public bool GetLump(BinaryStateLump lump, bool abort, Action <Stream, long> callback)
        {
            string   name = BinaryStateFileNames.GetReadName(lump);
            ZipEntry e;

            if (_entriesbyname.TryGetValue(name, out e))
            {
                using (var zs = _zip.GetInputStream(e))
                {
                    callback(zs, e.Size);
                }

                return(true);
            }

            if (abort)
            {
                throw new Exception("Essential zip section not found: " + name);
            }

            return(false);
        }
Пример #4
0
        /// <summary>
        /// Gets a lump
        /// </summary>
        /// <param name="lump">lump to retriever</param>
        /// <param name="abort">true to throw exception on failure</param>
        /// <param name="callback">function to call with the desired stream</param>
        /// <returns>true if callback was called and stream was loaded</returns>
        public bool GetLump(BinaryStateLump lump, bool abort, Action <Stream, long> callback)
        {
            var name = BinaryStateFileNames.Get(lump);
            var e    = _zip.GetEntry(name);

            if (e != null)
            {
                using (var zs = _zip.GetInputStream(e))
                {
                    callback(zs, e.Size);
                }

                return(true);
            }

            if (abort)
            {
                throw new Exception("Essential zip section not found: " + name);
            }

            return(false);
        }
Пример #5
0
        public void PutLump(BinaryStateLump lump, Action <Stream> callback)
        {
            var name = BinaryStateFileNames.GetWriteName(lump);

            _zip.WriteItem(name, callback);
        }