ReadInt64() public method

public ReadInt64 ( ) : long
return long
Example #1
1
 public IDictionary<byte[], IList<long>> Read(BinaryReader reader, int keyWidth)
 {
     var indexWidth = reader.ReadInt64();
     var buckets = new Dictionary<byte[], IList<long>>(new ByteArrayComparer());
     while (reader.BaseStream.Position < reader.BaseStream.Length)
     {
         var bucket = new List<long>();
         var index = reader.ReadBytes(keyWidth);
         for (int i = 0; i < indexWidth - keyWidth; i += sizeof (long))
         {
             var value = reader.ReadInt64();
             if (value != long.MaxValue)
             {
                 bucket.Add(value);
             }
             else
             {
                 reader.BaseStream.Seek(indexWidth - keyWidth - i - sizeof (long), SeekOrigin.Current);
                 break;
             }
         }
         buckets[index] = bucket;
     }
     return buckets;
 }
Example #2
0
 public Chests(BinaryReader inStream)
 {
     Id = inStream.ReadInt32();
     Flag0 = inStream.ReadBoolean();
     Unknown0 = inStream.ReadInt32();
     Name = inStream.ReadInt32();
     AnimatedObject = inStream.ReadInt32();
     Flag1 = inStream.ReadBoolean();
     Flag2 = inStream.ReadBoolean();
     Unknown1 = inStream.ReadInt32();
     Flag3 = inStream.ReadBoolean();
     Flag4 = inStream.ReadBoolean();
     Unknown2 = inStream.ReadInt32();
     Data0Length = inStream.ReadInt32();
     Data0 = inStream.ReadInt32();
     Data1Length = inStream.ReadInt32();
     Data1 = inStream.ReadInt32();
     ItemKey = inStream.ReadInt64();
     Flag5 = inStream.ReadBoolean();
     Data2Length = inStream.ReadInt32();
     Data2 = inStream.ReadInt32();
     Flag6 = inStream.ReadBoolean();
     Data3Length = inStream.ReadInt32();
     Data3 = inStream.ReadInt32();
     Unknown3 = inStream.ReadInt64();
     Unknown4 = inStream.ReadInt32();
     Flag7 = inStream.ReadBoolean();
     Data4Length = inStream.ReadInt32();
     Data4 = inStream.ReadInt32();
     Unknown23 = inStream.ReadInt32();
 }
Example #3
0
 public override void DeserializeBody(BinaryReader br)
 {
     dc_id = br.ReadInt32();
     volume_id = br.ReadInt64();
     local_id = br.ReadInt32();
     secret = br.ReadInt64();
 }
        public void Open()
        {
            if(!File.Exists(attributionFileName))
            {
                throw new FileNotFoundException("The specified attribution file is not found");
            }

            attributionFileStreamReader = new BinaryReader(File.Open(attributionFileName, FileMode.Open));
            attributionFileStreamReader.BaseStream.Seek(0, SeekOrigin.Begin);

            recordsCount = attributionFileStreamReader.ReadInt32();

            dataOffset = attributionFileStreamReader.ReadInt64();

            for (int i = 0; i < recordsCount; i++)
            {
                if (indexOffsets == null)
                {
                    indexOffsets = new Dictionary<int, long>();
                }

                indexOffsets.Add(i, attributionFileStreamReader.ReadInt64());
            }

            isOpened = true;
        }
Example #5
0
 public override void DeserializeBody(BinaryReader br)
 {
     id = br.ReadInt64();
     access_hash = br.ReadInt64();
     date = br.ReadInt32();
     sizes = (TLVector<TLAbsPhotoSize>)ObjectUtils.DeserializeVector<TLAbsPhotoSize>(br);
 }
Example #6
0
        public IEnumerable<FileEntry> ListFiles(Stream strm, Callbacks callbacks)
        {
            byte[] buf = new byte[4];
            BinaryReader rd = new BinaryReader(strm);
            int numFiles;
            List<FileEntry> results = new List<FileEntry>();

            rd.Read(buf, 0, 4);
            if (Encoding.ASCII.GetString(buf, 0, 4) != "TGP0")
                return results;

            if (rd.ReadInt32() != 1)  // version check
                return results;

            if (rd.ReadInt32() != 0)  // should be zero
                return results;

            numFiles = rd.ReadInt32();
            buf = new byte[0x60];
            for (int i = 0; i < numFiles; i++)
            {
                FileEntry ent = new FileEntry();

                rd.Read(buf, 0, 0x60);
                ent.Filename = Encoding.ASCII.GetString(buf);
                ent.Filename = ent.Filename.Substring(0, ent.Filename.IndexOf('\0'));
                ent.Offset = rd.ReadInt64();
                ent.UncompressedSize = rd.ReadInt64();

                results.Add(ent);
            }

            return results;
        }
Example #7
0
        public void TestWrite()
        {
            MemoryStream stream = new MemoryStream();

            // FileIndex should support a stream starting at any point
            stream.Seek(10, SeekOrigin.Begin);

            PostingListEncoder decoder = new PostingListEncoder();
            PerformWrite(stream);

            BinaryReader reader = new BinaryReader(stream);

            // Term count
            Assert.AreEqual(2, reader.ReadInt64());

            long ptr1 = reader.ReadInt64();
            long ptr2 = reader.ReadInt64();

            Assert.AreEqual(stream.Position, ptr1);
            Assert.AreEqual("aTerm", reader.ReadString());
            IList<Posting> postings = decoder.read(reader);
            Assert.AreEqual(2, postings.Count);
            Assert.AreEqual(new Posting(DocA, 1), postings[0]);
            Assert.AreEqual(new Posting(DocB, 1), postings[1]);

            Assert.AreEqual(stream.Position, ptr2);
            Assert.AreEqual("bTerm", reader.ReadString());
            postings = decoder.read(reader);
            Assert.AreEqual(3, postings.Count);
            Assert.AreEqual(new Posting(DocA, 1), postings[0]);
            Assert.AreEqual(new Posting(DocZ, 1), postings[1]);
            Assert.AreEqual(new Posting(DocT, 1), postings[2]);
        }
Example #8
0
        public ProgramHeader(BinaryReader reader, bool Is64Bit)
        {
            this.Type = (HeaderType)reader.ReadUInt32();

            // 64-bit reads flags here
            if (Is64Bit) { this.SegmentFlags = (SegmentFlags)reader.ReadUInt32(); }

            this.SegmentOffset  = Is64Bit ? reader.ReadInt64()  : reader.ReadUInt32();
            this.VirtualAddress = Is64Bit ? reader.ReadUInt64() : reader.ReadUInt32();

            // Skip physical address - reserved
            if (Is64Bit) reader.ReadUInt64(); else reader.ReadUInt32();

            this.SegmentFileSize   = Is64Bit ? reader.ReadInt64() : reader.ReadUInt32();
            this.SegmentLoadedSize = Is64Bit ? reader.ReadInt64() : reader.ReadUInt32();

            // 32-bit reads flags here
            if (!Is64Bit) { this.SegmentFlags = (SegmentFlags)reader.ReadUInt32(); }

            this.Alignment = Is64Bit ? reader.ReadInt64() : reader.ReadUInt32();

            if (this.SegmentOffset < 0 || this.SegmentFileSize < 0 ||
                this.SegmentLoadedSize < 0 || this.Alignment < 0)
            {
                throw new BadImageFormatException("Program header values are too large to be " +
                    "supported by this implementation");
            }
        }
Example #9
0
        public IndexedFS(Filesystem msys)
        {
            _msys = msys;
            if (!msys.EnumFiles().GetEnumerator().MoveNext())
            {
            //Create index
                msys.AllocSpace(0,512);
                Stream mstream = new ObservableStream(0, msys);
                BinaryWriter mwriter = new BinaryWriter(mstream);

                mwriter.Write(filemappings.Count);
                cval++;
            }
            ObservableStream fstr = new ObservableStream(0, msys);
            BinaryReader mreader = new BinaryReader(fstr);
            int count = mreader.ReadInt32();

            for (int i = 0; i < count; i++)
            {

                if (mreader.ReadBoolean())
                {
                    filemappings.Add(mreader.ReadString(), mreader.ReadInt64());
                }
                else
                {
                    dirmappings.Add(mreader.ReadString(), mreader.ReadInt64());

                }

                cval++;
            }
        }
 public void readHeader(BinaryReader reader)
 {
     this.operation = reader.ReadByte();
         int blockId = reader.ReadInt32();
         int threadId = IPAddress.NetworkToHostOrder(reader.ReadInt32());
         byte booleans = reader.ReadByte();
         if (isTrue(booleans, 1))
         {
             timeout = IPAddress.NetworkToHostOrder(reader.ReadInt64());
         }
         if (isTrue(booleans, 2))
         {
             ttl = IPAddress.NetworkToHostOrder(reader.ReadInt64());
         }
         if (isTrue(booleans, 4))
         {
             longValue = IPAddress.NetworkToHostOrder(reader.ReadInt64());
         }
         this.callId = IPAddress.NetworkToHostOrder(reader.ReadInt64());
         this.responseType = reader.ReadByte();
         int nameLength = IPAddress.NetworkToHostOrder(reader.ReadInt32());
         if (nameLength > 0)
         {
             byte[] b = new byte[nameLength];
             reader.Read(b, 0, nameLength);
             this.name = System.Text.Encoding.ASCII.GetString(b);
         }
         byte indexCount = reader.ReadByte();
         int keyPartitionHash = IPAddress.NetworkToHostOrder(reader.ReadInt32());
         int valuePartitionHash = IPAddress.NetworkToHostOrder(reader.ReadInt32());
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ContentArchiveNode"/> class from an archive stream.
        /// </summary>
        /// <param name="parent">The node's parent node.</param>
        /// <param name="reader">A <see cref="BinaryReader"/> on the stream containing the archive data.</param>
        private ContentArchiveNode(ContentArchiveNode parent, BinaryReader reader)
        {
            this.parent      = parent;
            this.name        = reader.ReadString();
            this.path        = BuildPath(parent, name);
            this.isFile      = reader.ReadBoolean();
            this.isDirectory = !this.isFile;

            if (this.isFile)
            {
                this.position    = reader.ReadInt64();
                this.sizeInBytes = reader.ReadInt64();
            }
            else
            {
                var childList = new List<ContentArchiveNode>();
                var childCount = reader.ReadInt32();

                for (int i = 0; i < childCount; i++)
                {
                    var node = new ContentArchiveNode(this, reader);
                    childList.Add(node);
                }

                this.children = childList;
            }
        }
Example #12
0
File: Cell.cs Project: pszmyd/SHS
        internal Partition part; // the partition containing this cell

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Load a cell from disk into memory.
        /// </summary>
        /// <param name="part">The partition where this cell belongs</param>
        /// <param name="fileName">The name of the file holding the persisted cell</param>
        /// <exception cref="FileFormatException">The cell file is malformed</exception>
        /// <exception cref="EndOfStreamException">The cell file is too short</exception>
        internal Cell(Partition part, string fileName, bool partial)
        {
            this.part = part;
              this.fileName = fileName;
              var fileLength = new FileInfo(fileName).Length;
              using (var br = new BinaryReader(new BufferedStream(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)))) {
            this.baseUID   = br.ReadInt64();
            this.epoch     = br.ReadInt32();
            this.numUrls   = br.ReadInt64();
            this.supraUID  = this.baseUID + this.numUrls;

            this.urlCell = new UrlCell(this, br);
            this.linkCell = new LinkCell[2];
            this.linkCell[0] = new LinkCell(this, br);
            this.linkCell[1] = new LinkCell(this, br);

            long numHdrBytes = br.BaseStream.Position;
            this.urlCell.startPos = numHdrBytes;
            this.linkCell[0].startPos = this.urlCell.startPos + this.urlCell.numBytes;
            this.linkCell[1].startPos = this.linkCell[0].startPos + this.linkCell[0].numBytes;
            var expectedSize = numHdrBytes + this.urlCell.numBytes +
              (partial ? 0L : this.linkCell[0].numBytes + this.linkCell[1].numBytes);
            if (fileLength != expectedSize) {
              throw new FileFormatException(fileName + " is wrong size");
            }
              }
        }
 protected override void ParseMessage(byte[] messageBody)
 {
     // Read double from the stream
     BinaryReader br = new BinaryReader(new MemoryStream(messageBody), Encoding.UTF8);
     X = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(br.ReadInt64()));
     Y = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(br.ReadInt64()));
 }
Example #14
0
        public void TestWrite()
        {
            Stream stream = new MemoryStream();
            PerformWrite(stream);

            BinaryReader reader = new BinaryReader(stream);
            stream.Seek(0, SeekOrigin.Begin);
            Assert.AreEqual(2, reader.ReadInt64());

            // term ptr, frequency
            reader.ReadInt64();
            Assert.AreEqual(2, reader.ReadInt32());

            // term ptr, frequency
            reader.ReadInt64();
            Assert.AreEqual(3, reader.ReadInt32());

            string[] strings = new string[] {
                "aTerm", "aDoc", "bDoc", "bTerm", "aDoc", "zDoc", "tDoc"
            };

            foreach (string str in strings)
            {
                Assert.AreEqual(str, reader.ReadString());
            }
        }
Example #15
0
 public override object Read(BinaryReader reader, byte version)
 {
     if (version == 0)
         return new Bid(new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
     else
         return new Bid(new DateTime(reader.ReadInt64()), new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
 }
 public override void DeserializeBody(BinaryReader br)
 {
     perm_auth_key_id = br.ReadInt64();
     nonce = br.ReadInt64();
     expires_at = br.ReadInt32();
     encrypted_message = BytesUtil.Deserialize(br);
 }
Example #17
0
 public DescentExiles(BinaryReader inStream)
 {
     Id = inStream.ReadInt32();
     AreaKey = inStream.ReadInt64();
     Unknown3 = inStream.ReadInt64();
     VarietyKey = inStream.ReadInt64();
     Unknown7 = inStream.ReadInt32();
 }
Example #18
0
		public override object Read(BinaryReader reader)
		{
			if (reader.ReadByte() == 0)
			{
				return new Ask(new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
			}
			return new Ask(new DateTime(reader.ReadInt64()), new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
		}
Example #19
0
 public DescentStarterChest(BinaryReader inStream)
 {
     Id = inStream.ReadInt32();
     Unknown1 = inStream.ReadInt64();
     Unknown2 = inStream.ReadInt64();
     Unknown3 = inStream.ReadInt32();
     Unknown4 = inStream.ReadInt64();
 }
Example #20
0
 public override void DeserializeBody(BinaryReader br)
 {
     id = br.ReadInt64();
     access_hash = br.ReadInt64();
     size = br.ReadInt32();
     dc_id = br.ReadInt32();
     key_fingerprint = br.ReadInt32();
 }
Example #21
0
 /// <summary>
 /// Reads back custom data from a raw representation of the data message.
 /// </summary>
 /// <param name="reader">The binary reader used to read from the raw representation of the original data message.</param>
 protected override void ReadData(BinaryReader reader)
 {
     var dateTimeTicks = reader.ReadInt64();
     var offsetTicks = reader.ReadInt64();
     var offset = TimeSpan.FromTicks(offsetTicks);
     Timestamp = new DateTimeOffset(dateTimeTicks, offset);
     Delta = new Vector2(reader.ReadSingle(), reader.ReadSingle());
 }
Example #22
0
 public ShrineBuffs(BinaryReader inStream)
 {
     Id = inStream.ReadInt32();
     Data0Length = inStream.ReadInt32();
     Data0 = inStream.ReadInt32();
     Unknown3 = inStream.ReadInt64();
     Unknown4 = inStream.ReadInt64();
 }
Example #23
0
 public MonsterPackEntries(BinaryReader inStream)
 {
     Index0 = inStream.ReadInt32();
     Unknown0 = inStream.ReadInt64();
     Flag0 = inStream.ReadBoolean();
     Unknown1 = inStream.ReadInt32();
     Unknown2 = inStream.ReadInt64();
 }
Example #24
0
		public void Read(BinaryReader reader)
		{
			Seed = reader.ReadInt32();
			Name = reader.ReadLongString();
			X = reader.ReadInt64();
			Y = reader.ReadInt64();
			Z = reader.ReadInt64();
		}
Example #25
0
        public AccountInfo(BinaryReader reader)
        {
            Index = reader.ReadInt32();

            AccountID = reader.ReadString();
            Password = reader.ReadString();

            UserName = reader.ReadString();
            BirthDate = DateTime.FromBinary(reader.ReadInt64());
            SecretQuestion = reader.ReadString();
            SecretAnswer = reader.ReadString();
            EMailAddress = reader.ReadString();

            CreationIP = reader.ReadString();
            CreationDate = DateTime.FromBinary(reader.ReadInt64());

            Banned = reader.ReadBoolean();
            BanReason = reader.ReadString();
            ExpiryDate = DateTime.FromBinary(reader.ReadInt64());

            LastIP = reader.ReadString();
            LastDate = DateTime.FromBinary(reader.ReadInt64());

            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                Characters.Add(new CharacterInfo(reader) { AccountInfo = this });
                
            }


            Gold = reader.ReadUInt32();
            if (Envir.LoadVersion >= 63) Credit = reader.ReadUInt32();

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                if (!reader.ReadBoolean()) continue;
                UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion);
                if (SMain.Envir.BindItem(item) && i < Storage.Length)
                    Storage[i] = item;
            }
            if (Envir.LoadVersion >= 10) AdminAccount = reader.ReadBoolean();
            if (!AdminAccount)
            {
                for (int i = 0; i < Characters.Count; i++)
                {
                    if (Characters[i] == null) continue;
                    if (Characters[i].Deleted) continue;
                    if ((DateTime.Now - Characters[i].LastDate).TotalDays > 13) continue;
                    if ((Characters[i].Level >= SMain.Envir.RankBottomLevel[0]) || (Characters[i].Level >= SMain.Envir.RankBottomLevel[(byte)Characters[i].Class + 1]))
                    {
                        SMain.Envir.CheckRankUpdate(Characters[i]);
                    }
                }
            }
        }
Example #26
0
 public void Read(BinaryReader br)
 {
     offsetWaveInfo = br.ReadInt64();
     offsetUnknownTable = br.ReadInt64();
     
     numBlocks = br.ReadInt32();
     numUnknownTableEntries = br.ReadInt32();
     headerSize = br.ReadInt32();
 }
Example #27
0
 public BuffVisuals(BinaryReader inStream)
 {
     Id = inStream.ReadInt32();
     BuffIcon = inStream.ReadInt32();
     EffectA = inStream.ReadInt32();
     EffectB = inStream.ReadInt32();
     Unknown4 = inStream.ReadInt64();
     Unknown5 = inStream.ReadInt64();
 }
Example #28
0
 public QuestStaticRewards(BinaryReader inStream)
 {
     Unknown0 = inStream.ReadInt32();
     Unknown1 = inStream.ReadInt32();
     Unknown2 = inStream.ReadInt64();
     Unknown3 = inStream.ReadInt32();
     Unknown4 = inStream.ReadInt64();
     Unknown5 = inStream.ReadInt64();
 }
Example #29
0
 public override void DeserializeBody(BinaryReader br)
 {
     id = br.ReadInt32();
     access_hash = br.ReadInt64();
     date = br.ReadInt32();
     admin_id = br.ReadInt32();
     participant_id = br.ReadInt32();
     g_a_or_b = BytesUtil.Deserialize(br);
     key_fingerprint = br.ReadInt64();
 }
Example #30
0
 public PlainMessage(byte[] raw, string type)
 {
     using (var br = new BinaryReader(new MemoryStream(raw)))
     {
         AuthKeyId = br.ReadInt64();
         MessageId = br.ReadInt64();
         int length = br.ReadInt32();
         Combinator = new Combinator(br.ReadBytes(length), type);
     }
 }