Ejemplo n.º 1
0
        public PakFile(FileSystem context, string filename)
        {
            Name = filename;
            index = new Dictionary<string, Entry>();

            stream = context.Open(filename);
            try
            {
                index = new Dictionary<string, Entry>();
                var offset = stream.ReadUInt32();
                while (offset != 0)
                {
                    var file = stream.ReadASCIIZ();
                    var next = stream.ReadUInt32();
                    var length = (next == 0 ? (uint)stream.Length : next) - offset;

                    // Ignore duplicate files
                    if (index.ContainsKey(file))
                        continue;

                    index.Add(file, new Entry { Offset = offset, Length = length, Filename = file });
                    offset = next;
                }
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Ejemplo n.º 2
0
        public D2kSoundResources(FileSystem context, string filename)
        {
            Name = filename;

            s = context.Open(filename);
            try
            {
                var headerLength = s.ReadUInt32();
                while (s.Position < headerLength + 4)
                {
                    var name = s.ReadASCIIZ();
                    var offset = s.ReadUInt32();
                    var length = s.ReadUInt32();
                    index.Add(name, new Entry(offset, length));
                }
            }
            catch
            {
                Dispose();
                throw;
            }
        }