예제 #1
0
        public ResourceEntry WriteMemFileEntry(ResourceEntry entry, XPathNodeIterator nodes, string sdsFolder, XmlNode descNode)
        {
            //get file name from XML.
            nodes.Current.MoveToNext();
            string file = nodes.Current.Value;

            nodes.Current.MoveToNext();
            entry.Version = Convert.ToUInt16(nodes.Current.Value);

            //construct MemResource.
            MemFileResource resource = new MemFileResource
            {
                Name = file,
                Unk1 = 1
            };

            using (BinaryReader reader = new BinaryReader(File.Open(sdsFolder + "/" + file, FileMode.Open)))
            {
                resource.Data         = reader.ReadBytes((int)reader.BaseStream.Length);
                entry.SlotRamRequired = (uint)reader.BaseStream.Length;
            }

            //serialize.
            MemoryStream stream = new MemoryStream();

            resource.Serialize(entry.Version, stream, Endian.Little);

            //set the data.
            entry.Data         = stream.GetBuffer();
            descNode.InnerText = file;
            return(entry);
        }
        public ResourceEntry WriteMemFileEntry(ResourceEntry entry, XPathNodeIterator nodes, string sdsFolder, XmlNode descNode)
        {
            //get file name from XML.
            nodes.Current.MoveToNext();
            string file = nodes.Current.Value;

            nodes.Current.MoveToNext();
            uint unk2 = Convert.ToUInt32(nodes.Current.Value);

            nodes.Current.MoveToNext();
            entry.Version = Convert.ToUInt16(nodes.Current.Value);

            //construct MemResource.
            MemFileResource resource = new MemFileResource
            {
                Name    = file,
                Unk1    = 1,
                Unk2_V4 = unk2
            };

            // Read all the data, then allocate memory required
            resource.Data         = File.ReadAllBytes(sdsFolder + "/" + file);
            entry.SlotRamRequired = (uint)resource.Data.Length;

            //serialize.
            using (MemoryStream stream = new MemoryStream())
            {
                resource.Serialize(entry.Version, stream, Endian.Little);
                entry.Data = stream.ToArray();
            }

            descNode.InnerText = file;
            return(entry);
        }