예제 #1
0
        public void Show(ArchiveListing listing, ArchiveEntry entry)
        {
            _listing = listing;
            _entry = entry;

            if (listing == null || entry == null)
            {
                _textBox.Text = null;
                return;
            }

            FFXIIITextEncoding encoding = InteractionService.TextEncoding.Provide().Encoding;

            ZtrFileEntry[] entries;
            using (Stream data = listing.Accessor.ExtractBinary(entry))
            {
                ZtrFileUnpacker unpacker = new ZtrFileUnpacker(data, encoding);
                entries = unpacker.Unpack();
            }

            if (entries.IsNullOrEmpty())
                return;

            using (MemoryStream ms = new MemoryStream(4096))
            {
                ZtrTextWriter writer = new ZtrTextWriter(ms, StringsZtrFormatter.Instance);
                writer.Write(entry.Name, entries);

                ms.Position = 0;
                using (StreamReader sr = new StreamReader(ms, System.Text.Encoding.UTF8, false))
                    _textBox.Text = sr.ReadToEnd();
            }

            Visibility = Visibility.Visible;
        }
        public void Extract(ArchiveEntry entry, StreamSequence output, Stream input, Byte[] buff)
        {
            int size = (int)entry.UncompressedSize;
            if (size == 0)
                return;

            ZtrFileUnpacker unpacker = new ZtrFileUnpacker(input, InteractionService.TextEncoding.Provide().Encoding);
            ZtrFileEntry[] entries = unpacker.Unpack();

            ZtrTextWriter writer = new ZtrTextWriter(output, StringsZtrFormatter.Instance);
            writer.Write(entry.Name, entries);
        }