Ejemplo n.º 1
0
        public byte[] Export(string[] Content)
        {
            using (var Strm = new MemoryStream())
                using (StructWriter Writer = new StructWriter(Strm, Encoding: Encoding))
                {
                    var File = new TextDataFormat();
                    File.Content = Content;

                    File.Count   = Content.Length;
                    File.Offsets = new TextDataEntryOffset[File.Count];

                    var Offset = 16 + (16 * File.Count);

                    for (int i = 0; i < Content.Length; i++)
                    {
                        File.Offsets[i] = new TextDataEntryOffset()
                        {
                            Offset = Offset
                        };

                        Offset += Encoding.GetByteCount(Content[i] + '\x0');
                    }

                    Writer.WriteStruct(ref File);
                    Writer.Flush();

                    foreach (var String in Content)
                    {
                        Writer.WriteString(String, StringStyle.CString);
                    }


                    return(Strm.ToArray());
                }
        }
Ejemplo n.º 2
0
        public string[] Import()
        {
            using (Stream Strm = new MemoryStream(Script))
                using (StructReader Reader = new StructReader(Strm, Encoding: Encoding))
                {
                    var File = new TextDataFormat();
                    Reader.ReadStruct(ref File);

                    File.Content = new string[File.Count];
                    for (int i = 0; i < File.Offsets.Length; i++)
                    {
                        Reader.Position = File.Offsets[i].Offset;
                        File.Content[i] = Reader.ReadString(StringStyle.CString);
                    }

                    return(File.Content);
                }
        }