예제 #1
0
        public void EndWriting()
        {
            if (!_writing)
            {
                throw new Exception("BeginWriting() must be called before called EndWriting()");
            }

            foreach (var kvp in _bufferTable)
            {
                var offset = 0U;

                foreach (var file in kvp.Value.Data)
                {
                    var position = _writer.WriteData(_archiveTable[kvp.Key], file);

                    if (offset == 0)
                    {
                        offset = (uint)position;
                    }
                }

                foreach (var info in kvp.Value.Metadata)
                {
                    _archiveTable[kvp.Key].Files[info.Path].DataLength = info.DataLength;
                    _archiveTable[kvp.Key].Files[info.Path].DataOffset = offset + info.DataOffset;
                }

                _writer.WriteArchive(_archiveTable[kvp.Key], _archiveTable[kvp.Key].FilePath);
                Console.WriteLine("Archive written to {0}", kvp.Key);
            }

            WriteStateInfo();

            _writing = false;
        }