Unmount() 공개 메소드

public Unmount ( IReadOnlyPackage package ) : bool
package IReadOnlyPackage
리턴 bool
예제 #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
            context.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);
                }
            }
        }
예제 #2
0
파일: BagFile.cs 프로젝트: huwpascoe/OpenRA
 public void Write(Dictionary <string, byte[]> contents)
 {
     context.Unmount(this);
     throw new NotImplementedException("Updating bag files unsupported");
 }