Beispiel #1
0
        public void Write(Dictionary <string, byte[]> contents)
        {
            // Cannot modify existing mixfile - rename existing file and
            // create a new one with original content plus modifications
            GlobalFileSystem.Unmount(this);

            // TODO: Add existing data to the contents list
            if (index.Count > 0)
            {
                throw new NotImplementedException("Updating mix files unfinished");
            }

            // Construct a list of entries for the file header
            uint dataSize = 0;
            var  items    = new List <PackageEntry>();

            foreach (var kv in contents)
            {
                var length = (uint)kv.Value.Length;
                var hash   = PackageEntry.HashFilename(Path.GetFileName(kv.Key), type);
                items.Add(new PackageEntry(hash, dataSize, length));
                dataSize += length;
            }

            // Write the new file
            s.Seek(0, SeekOrigin.Begin);
            using (var writer = new BinaryWriter(s))
            {
                // Write file header
                writer.Write((ushort)items.Count);
                writer.Write(dataSize);
                foreach (var item in items)
                {
                    item.Write(writer);
                }

                writer.Flush();

                // Copy file data
                foreach (var file in contents)
                {
                    s.Write(file.Value);
                }
            }
        }
Beispiel #2
0
 public void Write(Dictionary <string, byte[]> contents)
 {
     GlobalFileSystem.Unmount(this);
     throw new NotImplementedException("Updating bag files unsupported");
 }