Esempio n. 1
0
        /// <summary>
        /// Creates a new TagFile wrapping the provided metadata.
        /// </summary>
        /// <param name="dataStream">metadata stream to wrap</param>
        public TagFile(byte[] dataStream, string author, string information, string tagType, string parentType, string grandparentType, byte[] gameID)
        {
            this.tagType         = tagType;
            this.parentType      = parentType;
            this.grandparentType = grandparentType;
            game         = gameID;
            headRevision = 0;

            binaryBlobs = new List <byte[]>();
            binaryBlobs.Add(dataStream);

            authors = new List <string>();
            authors.Add(author);

            informations = new List <string>();
            informations.Add(information);

            revisions = new List <ObjectRevision>();
            ObjectRevision revision = new ObjectRevision();

            revision.AuthorLength     = (short)authors[headRevision].Length;
            revision.InfoLength       = (short)informations[headRevision].Length;
            revision.DataLength       = dataStream.Length;
            revision.CompressionStyle = CompressionStyle.GZip;
            revision.Date             = DateTime.Now;
            revision.Version          = 1.0f;
            revisions.Add(revision);
        }
Esempio n. 2
0
            public virtual void Read(Stream stream)
            {
                byte[] buffer = new byte[AttachmentSize];
                stream.Read(buffer, 0, AttachmentSize);

                headRevision   = BitConverter.ToInt32(buffer, 0);
                revisionCount  = BitConverter.ToInt32(buffer, 4);
                revisionOffset = BitConverter.ToInt32(buffer, 8);
                reserved_a     = BitConverter.ToInt32(buffer, 12);
                reserved_b     = BitConverter.ToInt32(buffer, 16);
                reserved_c     = BitConverter.ToInt32(buffer, 20);
                reserved_d     = BitConverter.ToInt32(buffer, 24);
                reserved_e     = BitConverter.ToInt32(buffer, 28);
                name           = new byte[NameSize];
                for (int i = 0; i < NameSize; i++)
                {
                    name[i] = buffer[i + 32];
                }

                long position = stream.Position;

                stream.Position = revisionOffset;
                for (int i = 0; i < revisionCount; i++)
                {
                    ObjectRevision revision = new ObjectRevision();
                    revision.Read(stream);
                    revisions.Add(revision);
                }
                for (int i = 0; i < revisionCount; i++)
                {
                    stream.Position = revisions[i].DataOffset;
                    byte[] data = new byte[revisions[i].DataLength];
                    stream.Read(data, 0, revisions[i].DataLength);
                    datas.Add(data);
                }

                stream.Position = position;
            }