コード例 #1
0
        void ReadTableOfContents()
        {
            Stream stream = null;

            try
            {
                stream = mappedFile.CreateViewStream(0, 0, MemoryMappedFileAccess.Read);
                using (var reader = new BinaryReader(stream, Encoding.ASCII))
                {
                    stream = null;
                    var entryCount = reader.ReadUInt32() - 1;

                    for (int i = 0; i < entryCount; i++)
                    {
                        var index        = i;
                        var startAddress = reader.ReadUInt32();
                        var name         = reader.ReadFixedString(NameLength).Trim();
                        var size         = reader.ReadInt32() - startAddress;

                        reader.BaseStream.Position -= sizeof(uint);

                        var entry = new FileArchiveEntry
                        {
                            Index  = index,
                            Name   = name,
                            Offset = startAddress,
                            Size   = size
                        };

                        entries[name] = entry;
                    }
                }
            }
            finally { stream?.Dispose(); }
        }
コード例 #2
0
ファイル: FileArchive.cs プロジェクト: ewrogers/SleepHunter4
        void ReadTableOfContents()
        {
            Stream stream = null;
              try
              {
            stream = mappedFile.CreateViewStream(0, 0, MemoryMappedFileAccess.Read);
            using (var reader = new BinaryReader(stream, Encoding.ASCII))
            {
              stream = null;
              var entryCount = reader.ReadUInt32() - 1;

              for (int i = 0; i < entryCount; i++)
              {
            var index = i;
            var startAddress = reader.ReadUInt32();
            var name = reader.ReadFixedString(NameLength).Trim();
            var size = reader.ReadInt32() - startAddress;

            reader.BaseStream.Position -= sizeof(uint);

            var entry = new FileArchiveEntry
            {
              Index = index,
              Name = name,
              Offset = startAddress,
              Size = size
            };

            entries[name] = entry;
              }
            }
              }
              finally { stream?.Dispose(); }
        }