Пример #1
0
    /*
     * Loads the sprite data and index files from the cache location.
     * This can be edited to use an archive such as config or media to load from the cache.
     *
     * @param archive
     */
    public static void loadSprites(StreamLoader streamLoader)
    {
        //try {
        RS2Sharp.Stream index        = new RS2Sharp.Stream(UnityClient.ReadAllBytes(signlink.findcachedir() + "sprites.idx"));
        RS2Sharp.Stream data         = new RS2Sharp.Stream(UnityClient.ReadAllBytes(signlink.findcachedir() + "sprites.dat"));
        DataInputStream indexFile    = new DataInputStream(new Ionic.Zlib.GZipStream(new MemoryStream(index.buffer), Ionic.Zlib.CompressionMode.Decompress));
        DataInputStream dataFile     = new DataInputStream(new Ionic.Zlib.GZipStream(new MemoryStream(data.buffer), Ionic.Zlib.CompressionMode.Decompress));
        int             totalSprites = indexFile.ReadInt();

        UnityEngine.Debug.Log("Sprites loaded: " + totalSprites);
        if (cache == null)
        {
            cache   = new SpriteLoader[totalSprites];
            sprites = new Sprite[totalSprites];
        }
        for (int i = 0; i < totalSprites; i++)
        {
            int id = indexFile.ReadInt();
            if (cache[id] == null)
            {
                cache[id] = new SpriteLoader();
            }
            cache[id].readValues(indexFile, dataFile);
            createSprite(cache[id]);
        }
        //indexFile.Close();
        //dataFile.Close();
        //} catch (Exception e) {
        //	e.printStackTrace();
        //}
    }
Пример #2
0
        private void HandleInvitation(DataInputStream dataInputStream, model.RtpMidiServer rtpMidiServer)
        {
            int protocolVersion = dataInputStream.ReadInt();

            if (protocolVersion != PROTOCOL_VERSION)
            {
                Log.Info("RtpMidi", "Protocol version: {} did not match version {}", protocolVersion, PROTOCOL_VERSION);
                return;
            }
            int initiatorToken = dataInputStream.ReadInt();
            int ssrc           = dataInputStream.ReadInt();
            //Scanner scanner = new Scanner(dataInputStream).UseDelimiter(NUL_TERMINATOR);
            //if (!scanner.HasNext)
            //{
            //    Log.Info("RtpMidi","Could not find \\0 terminating string");
            //    return;
            //}
            //string name = scanner.Next();
            string name = dataInputStream.ReadLine();

            foreach (IRtpMidiCommandListener listener in listeners)
            {
                listener.OnMidiInvitation(new RtpMidiInvitationRequest(protocolVersion, initiatorToken, ssrc, name), rtpMidiServer);
            }
        }
Пример #3
0
 /// <summary>A TagCount object's fields are read from the file.</summary>
 /// <remarks>
 /// A TagCount object's fields are read from the file. They are read from
 /// the current position and the file is not closed afterwards.
 /// </remarks>
 public static Edu.Stanford.Nlp.Tagger.Maxent.TagCount ReadTagCount(DataInputStream rf)
 {
     try
     {
         Edu.Stanford.Nlp.Tagger.Maxent.TagCount tc = new Edu.Stanford.Nlp.Tagger.Maxent.TagCount();
         int numTags = rf.ReadInt();
         tc.map = Generics.NewHashMap(numTags);
         for (int i = 0; i < numTags; i++)
         {
             string tag   = rf.ReadUTF();
             int    count = rf.ReadInt();
             if (tag.Equals(NullSymbol))
             {
                 tag = null;
             }
             tc.map[tag] = count;
         }
         tc.getTagsCache = Sharpen.Collections.ToArray(tc.map.Keys, new string[tc.map.Keys.Count]);
         tc.sumCache     = tc.CalculateSumCache();
         return(tc);
     }
     catch (IOException e)
     {
         throw new RuntimeIOException(e);
     }
 }
Пример #4
0
        /// <summary>Read word vectors from an input stream.</summary>
        /// <remarks>Read word vectors from an input stream. The stream is not closed on finishing the function.</remarks>
        /// <param name="in">The stream to read from. This is not closed.</param>
        /// <returns>The word vectors encoded on the stream.</returns>
        /// <exception cref="System.IO.IOException">Thrown if we could not read from the stream.</exception>
        public static VectorMap Deserialize(InputStream @in)
        {
            DataInputStream dataIn = new DataInputStream(@in);

            // Read the max key length
            VectorMap.Itype keyIntType = VectorMap.Itype.GetType(dataIn.ReadInt());
            // Read the vector dimensionality
            int dim = dataIn.ReadInt();
            // Read the size of the dataset
            int size = dataIn.ReadInt();
            // Read the vectors
            VectorMap vectors = new VectorMap();

            for (int i = 0; i < size; ++i)
            {
                // Read the key
                int    strlen = keyIntType.Read(dataIn);
                byte[] buffer = new byte[strlen];
                if (dataIn.Read(buffer, 0, strlen) != strlen)
                {
                    throw new IOException("Could not read string buffer fully!");
                }
                string key = Sharpen.Runtime.GetStringForBytes(buffer);
                // Read the vector
                float[] vector = new float[dim];
                for (int k = 0; k < vector.Length; ++k)
                {
                    vector[k] = ToFloat(dataIn.ReadShort());
                }
                // Add the key/value
                vectors[key] = vector;
            }
            return(vectors);
        }
Пример #5
0
        // protected constructor -------------------------------------------

        /// <summary>
        /// Trie constructor for CharTrie use.
        /// </summary>
        ///
        /// <param name="inputStream">ICU data file input stream which contains the trie</param>
        /// <param name="dataManipulate">object containing the information to parse the trie data</param>
        /// <exception cref="IOException">thrown when input stream does not have the right header.</exception>
        /// @draft 2.1
        protected internal Trie(DataInputStream inputStream, Trie.DataManipulate dataManipulate)
        {
            DataInputStream input = inputStream; // new DataInputStream(inputStream);
            // Magic number to authenticate the data.
            int signature = input.ReadInt();

            m_options_ = input.ReadInt();

            if (!CheckHeader(signature))
            {
                throw new ArgumentException(
                          "ICU data file error: Trie header authentication failed, please check if you have the most updated ICU data file");
            }

            if (dataManipulate != null)
            {
                m_dataManipulate_ = dataManipulate;
            }
            else
            {
                m_dataManipulate_ = new Trie.DefaultGetFoldingOffset();
            }
            m_isLatin1Linear_ = (m_options_ & HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_) != 0;
            m_dataOffset_     = input.ReadInt();
            m_dataLength_     = input.ReadInt();
            Unserialize(inputStream);
        }
        private void ReadData(Stream stream)
        {
            DataInputStream ds = new DataInputStream(stream);

            /* if (DEBUG)
             *   System.Console.Out.WriteLine("The DataInputStream class is: "
             + ds.GetType().FullName);
             + if (DEBUG)
             +   System.Console.Out
             +           .WriteLine("The available bytes in the stream before reading the data: "
             + ds.Available());
             */
            /*
             * The following will read two integers before ds.mark(). Later, the two
             * integers need to be placed into data[], then ds.reset(), then
             * ds.readFully(into rest of data[]).
             *
             * This is necessary because we don't know the readLimit for ds.mark()
             * until we have read the second integer (indexLength).
             */
            rootRes = ds.ReadInt();

            // read the variable-length indexes[] array
            int indexLength = ds.ReadInt();

            ds.Mark((indexLength - 1) * 4);

            indexes = new int[indexLength];
            indexes[URES_INDEX_LENGTH] = indexLength;

            for (int i = 1; i < indexLength; i++)
            {
                indexes[i] = ds.ReadInt();
            }

            // determine if this resource bundle falls back to a parent bundle
            // along normal locale ID fallback
            noFallback = indexLength > URES_INDEX_ATTRIBUTES &&
                         (indexes[URES_INDEX_ATTRIBUTES] & URES_ATT_NO_FALLBACK) != 0;

            // read the entire bundle (after the header) into data[]
            // put rootRes and indexLength into data[0..7]
            // and the rest of the data into data[8..length-1]
            int length = indexes[URES_INDEX_BUNDLE_TOP] * 4;

            if (DEBUG)
            {
                System.Console.Out.WriteLine("The number of bytes in the bundle: " + length);
            }

            data = new sbyte[length];
            WriteInt(rootRes, data, 0);
            WriteInt(indexLength, data, 4);

            // now reset to the mark, which was set after reading rootRes and
            // indexLength
            ds.Reset();
            ds.ReadFully(data, 8, length - 8);
        }
        public override void FromInputStream(DataInputStream reader)
        {
            int actionID = reader.ReadInt();

            try {
                PerformedAction = (ButtonAction)actionID;
                SlotID          = reader.ReadInt();
            } catch (Exception) {
                //Ignore malformed packet
            }
        }
Пример #8
0
        /// <exception cref="System.IO.IOException"/>
        private void ProcessDirectoryDiff(DataInputStream @in, ImageVisitor v, string currentINodeName
                                          )
        {
            v.VisitEnclosingElement(ImageVisitor.ImageElement.SnapshotDirDiff);
            int snapshotId = @in.ReadInt();

            v.Visit(ImageVisitor.ImageElement.SnapshotDiffSnapshotid, snapshotId);
            v.Visit(ImageVisitor.ImageElement.SnapshotDirDiffChildrenSize, @in.ReadInt());
            // process snapshotINode
            bool useRoot = @in.ReadBoolean();

            if (!useRoot)
            {
                if (@in.ReadBoolean())
                {
                    v.VisitEnclosingElement(ImageVisitor.ImageElement.SnapshotInodeDirectoryAttributes
                                            );
                    if (NameNodeLayoutVersion.Supports(LayoutVersion.Feature.OptimizeSnapshotInodes,
                                                       imageVersion))
                    {
                        ProcessINodeDirectoryAttributes(@in, v, currentINodeName);
                    }
                    else
                    {
                        ProcessINode(@in, v, true, currentINodeName, true);
                    }
                    v.LeaveEnclosingElement();
                }
            }
            // process createdList
            int createdSize = @in.ReadInt();

            v.VisitEnclosingElement(ImageVisitor.ImageElement.SnapshotDirDiffCreatedlist, ImageVisitor.ImageElement
                                    .SnapshotDirDiffCreatedlistSize, createdSize);
            for (int i = 0; i < createdSize; i++)
            {
                string createdNode = FSImageSerialization.ReadString(@in);
                v.Visit(ImageVisitor.ImageElement.SnapshotDirDiffCreatedInode, createdNode);
            }
            v.LeaveEnclosingElement();
            // process deletedList
            int deletedSize = @in.ReadInt();

            v.VisitEnclosingElement(ImageVisitor.ImageElement.SnapshotDirDiffDeletedlist, ImageVisitor.ImageElement
                                    .SnapshotDirDiffDeletedlistSize, deletedSize);
            for (int i_1 = 0; i_1 < deletedSize; i_1++)
            {
                v.VisitEnclosingElement(ImageVisitor.ImageElement.SnapshotDirDiffDeletedInode);
                ProcessINode(@in, v, false, currentINodeName, true);
                v.LeaveEnclosingElement();
            }
            v.LeaveEnclosingElement();
            v.LeaveEnclosingElement();
        }
Пример #9
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._entityID.Unmarshal(dis);
                    this._forceId = dis.ReadUnsignedByte();
                    this._articulationParameterCount = dis.ReadByte();
                    this._entityType.Unmarshal(dis);
                    this._alternativeEntityType.Unmarshal(dis);
                    this._entityLinearVelocity.Unmarshal(dis);
                    this._entityLocation.Unmarshal(dis);
                    this._entityOrientation.Unmarshal(dis);
                    this._entityAppearance = dis.ReadInt();
                    this._deadReckoningParameters.Unmarshal(dis);

                    for (int idx = 0; idx < this._marking.Length; idx++)
                    {
                        this._marking[idx] = dis.ReadByte();
                    }

                    this._capabilities = dis.ReadInt();

                    for (int idx = 0; idx < this.ArticulationParameterCount; idx++)
                    {
                        ArticulationParameter anX = new ArticulationParameter();
                        anX.Unmarshal(dis);
                        this._articulationParameters.Add(anX);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Пример #10
0
        // DELEGATION_TOKENS
        /// <summary>Process the INodes under construction section of the fsimage.</summary>
        /// <param name="in">DataInputStream to process</param>
        /// <param name="v">Visitor to walk over inodes</param>
        /// <param name="skipBlocks">Walk over each block?</param>
        /// <exception cref="System.IO.IOException"/>
        private void ProcessINodesUC(DataInputStream @in, ImageVisitor v, bool skipBlocks
                                     )
        {
            int numINUC = @in.ReadInt();

            v.VisitEnclosingElement(ImageVisitor.ImageElement.InodesUnderConstruction, ImageVisitor.ImageElement
                                    .NumInodesUnderConstruction, numINUC);
            for (int i = 0; i < numINUC; i++)
            {
                v.VisitEnclosingElement(ImageVisitor.ImageElement.InodeUnderConstruction);
                byte[] name = FSImageSerialization.ReadBytes(@in);
                string n    = Sharpen.Runtime.GetStringForBytes(name, "UTF8");
                v.Visit(ImageVisitor.ImageElement.InodePath, n);
                if (NameNodeLayoutVersion.Supports(LayoutVersion.Feature.AddInodeId, imageVersion
                                                   ))
                {
                    long inodeId = @in.ReadLong();
                    v.Visit(ImageVisitor.ImageElement.InodeId, inodeId);
                }
                v.Visit(ImageVisitor.ImageElement.Replication, @in.ReadShort());
                v.Visit(ImageVisitor.ImageElement.ModificationTime, FormatDate(@in.ReadLong()));
                v.Visit(ImageVisitor.ImageElement.PreferredBlockSize, @in.ReadLong());
                int numBlocks = @in.ReadInt();
                ProcessBlocks(@in, v, numBlocks, skipBlocks);
                ProcessPermission(@in, v);
                v.Visit(ImageVisitor.ImageElement.ClientName, FSImageSerialization.ReadString(@in
                                                                                              ));
                v.Visit(ImageVisitor.ImageElement.ClientMachine, FSImageSerialization.ReadString(
                            @in));
                // Skip over the datanode descriptors, which are still stored in the
                // file but are not used by the datanode or loaded into memory
                int numLocs = @in.ReadInt();
                for (int j = 0; j < numLocs; j++)
                {
                    @in.ReadShort();
                    @in.ReadLong();
                    @in.ReadLong();
                    @in.ReadLong();
                    @in.ReadInt();
                    FSImageSerialization.ReadString(@in);
                    FSImageSerialization.ReadString(@in);
                    WritableUtils.ReadEnum <DatanodeInfo.AdminStates>(@in);
                }
                v.LeaveEnclosingElement();
            }
            // INodeUnderConstruction
            v.LeaveEnclosingElement();
        }
Пример #11
0
        /// <summary>Process the Delegation Token related section in fsimage.</summary>
        /// <param name="in">DataInputStream to process</param>
        /// <param name="v">Visitor to walk over records</param>
        /// <exception cref="System.IO.IOException"/>
        private void ProcessDelegationTokens(DataInputStream @in, ImageVisitor v)
        {
            v.Visit(ImageVisitor.ImageElement.CurrentDelegationKeyId, @in.ReadInt());
            int numDKeys = @in.ReadInt();

            v.VisitEnclosingElement(ImageVisitor.ImageElement.DelegationKeys, ImageVisitor.ImageElement
                                    .NumDelegationKeys, numDKeys);
            for (int i = 0; i < numDKeys; i++)
            {
                DelegationKey key = new DelegationKey();
                key.ReadFields(@in);
                v.Visit(ImageVisitor.ImageElement.DelegationKey, key.ToString());
            }
            v.LeaveEnclosingElement();
            v.Visit(ImageVisitor.ImageElement.DelegationTokenSequenceNumber, @in.ReadInt());
            int numDTokens = @in.ReadInt();

            v.VisitEnclosingElement(ImageVisitor.ImageElement.DelegationTokens, ImageVisitor.ImageElement
                                    .NumDelegationTokens, numDTokens);
            for (int i_1 = 0; i_1 < numDTokens; i_1++)
            {
                DelegationTokenIdentifier id = new DelegationTokenIdentifier();
                id.ReadFields(@in);
                long expiryTime = @in.ReadLong();
                v.VisitEnclosingElement(ImageVisitor.ImageElement.DelegationTokenIdentifier);
                v.Visit(ImageVisitor.ImageElement.DelegationTokenIdentifierKind, id.GetKind().ToString
                            ());
                v.Visit(ImageVisitor.ImageElement.DelegationTokenIdentifierSeqno, id.GetSequenceNumber
                            ());
                v.Visit(ImageVisitor.ImageElement.DelegationTokenIdentifierOwner, id.GetOwner().ToString
                            ());
                v.Visit(ImageVisitor.ImageElement.DelegationTokenIdentifierRenewer, id.GetRenewer
                            ().ToString());
                v.Visit(ImageVisitor.ImageElement.DelegationTokenIdentifierRealuser, id.GetRealUser
                            ().ToString());
                v.Visit(ImageVisitor.ImageElement.DelegationTokenIdentifierIssueDate, id.GetIssueDate
                            ());
                v.Visit(ImageVisitor.ImageElement.DelegationTokenIdentifierMaxDate, id.GetMaxDate
                            ());
                v.Visit(ImageVisitor.ImageElement.DelegationTokenIdentifierExpiryTime, expiryTime
                        );
                v.Visit(ImageVisitor.ImageElement.DelegationTokenIdentifierMasterKeyId, id.GetMasterKeyId
                            ());
                v.LeaveEnclosingElement();
            }
            // DELEGATION_TOKEN_IDENTIFIER
            v.LeaveEnclosingElement();
        }
Пример #12
0
        // private methods ---------------------------------------------------

        /// <summary>
        /// Reads an individual record of AlgorithmNames
        /// </summary>
        ///
        /// <returns>an instance of AlgorithNames if read is successful otherwise null</returns>
        /// <exception cref="IOException">thrown when file read error occurs or data is corrupted</exception>
        private UCharacterName.AlgorithmName ReadAlg()
        {
            UCharacterName.AlgorithmName result = new UCharacterName.AlgorithmName();
            int   rangestart = m_dataInputStream_.ReadInt();
            int   rangeend   = m_dataInputStream_.ReadInt();
            sbyte type       = m_dataInputStream_.ReadByte();
            sbyte variant    = m_dataInputStream_.ReadByte();

            if (!result.SetInfo(rangestart, rangeend, type, variant))
            {
                return(null);
            }

            int size = m_dataInputStream_.ReadChar();

            if (type == IBM.ICU.Impl.UCharacterName.AlgorithmName.TYPE_1_)
            {
                char[] factor = new char[variant];
                for (int j = 0; j < variant; j++)
                {
                    factor[j] = m_dataInputStream_.ReadChar();
                }

                result.SetFactor(factor);
                size -= (variant << 1);
            }

            StringBuilder prefix = new StringBuilder();
            char          c      = (char)(m_dataInputStream_.ReadByte() & 0x00FF);

            while (c != 0)
            {
                prefix.Append(c);
                c = (char)(m_dataInputStream_.ReadByte() & 0x00FF);
            }

            result.SetPrefix(prefix.ToString());

            size -= (ALG_INFO_SIZE_ + prefix.Length + 1);

            if (size > 0)
            {
                byte[] str0 = new byte[size];
                m_dataInputStream_.ReadFully(str0);
                result.SetFactorString(str0);
            }
            return(result);
        }
Пример #13
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._originatingSimulationAddress.Unmarshal(dis);
                    this._padding1 = dis.ReadInt();
                    this._padding2 = dis.ReadShort();
                    this._attributeRecordPduType         = dis.ReadUnsignedByte();
                    this._attributeRecordProtocolVersion = dis.ReadUnsignedByte();
                    this._masterAttributeRecordType      = dis.ReadUnsignedInt();
                    this._actionCode = dis.ReadUnsignedByte();
                    this._padding3   = dis.ReadByte();
                    this._numberAttributeRecordSet = dis.ReadUnsignedShort();
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
Пример #14
0
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._numberOfPdus = dis.ReadInt();

                    for (int idx = 0; idx < this.NumberOfPdus; idx++)
                    {
                        Pdu anX = new Pdu();
                        anX.Unmarshal(dis);
                        this._pdus.Add(anX);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Пример #15
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._entityID.Unmarshal(dis);
                    this._padding1 = dis.ReadByte();
                    this._numberOfArticulationParameters = dis.ReadUnsignedByte();
                    this._entityLinearVelocity.Unmarshal(dis);
                    this._entityLocation.Unmarshal(dis);
                    this._entityOrientation.Unmarshal(dis);
                    this._entityAppearance = dis.ReadInt();
                    for (int idx = 0; idx < this.NumberOfArticulationParameters; idx++)
                    {
                        ArticulationParameter anX = new ArticulationParameter();
                        anX.Unmarshal(dis);
                        this._articulationParameters.Add(anX);
                    }
                    ;
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
Пример #16
0
        /// <exception cref="System.IO.IOException"/>
        private static int ReadLeadingInt(Text txt)
        {
            DataInputStream @in = new DataInputStream(new ByteArrayInputStream(txt.GetBytes()
                                                                               ));

            return(@in.ReadInt());
        }
        /// <exception cref="System.IO.IOException"/>
        private void ProcessTokenAddOrUpdate(ChildData data)
        {
            ByteArrayInputStream bin   = new ByteArrayInputStream(data.GetData());
            DataInputStream      din   = new DataInputStream(bin);
            TokenIdent           ident = CreateIdentifier();

            ident.ReadFields(din);
            long renewDate = din.ReadLong();
            int  pwdLen    = din.ReadInt();

            byte[] password = new byte[pwdLen];
            int    numRead  = din.Read(password, 0, pwdLen);

            if (numRead > -1)
            {
                AbstractDelegationTokenSecretManager.DelegationTokenInformation tokenInfo = new AbstractDelegationTokenSecretManager.DelegationTokenInformation
                                                                                                (renewDate, password);
                lock (this)
                {
                    currentTokens[ident] = tokenInfo;
                    // The cancel task might be waiting
                    Runtime.NotifyAll(this);
                }
            }
        }
Пример #18
0
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._numberOfPdus = dis.ReadInt();
                    for (int idx = 0; idx < this.NumberOfPdus; idx++)
                    {
                        Pdu anX = new Pdu();
                        anX.Unmarshal(dis);
                        this._pdus.Add(anX);
                    }
                    ;
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
 /// <exception cref="System.IO.IOException"/>
 private void LoadLatestSequenceNumber(TimelineStateStore.TimelineServiceState state
                                       )
 {
     byte[] data = null;
     try
     {
         data = db.Get(LatestSequenceNumberKey);
     }
     catch (DBException e)
     {
         throw new IOException(e);
     }
     if (data != null)
     {
         DataInputStream @in = new DataInputStream(new ByteArrayInputStream(data));
         try
         {
             state.latestSequenceNumber = @in.ReadInt();
         }
         finally
         {
             IOUtils.Cleanup(Log, @in);
         }
     }
 }
Пример #20
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._munitionID.Unmarshal(dis);
                    this._eventID.Unmarshal(dis);
                    this._fireMissionIndex = dis.ReadInt();
                    this._locationInWorldCoordinates.Unmarshal(dis);
                    this._burstDescriptor.Unmarshal(dis);
                    this._velocity.Unmarshal(dis);
                    this._range = dis.ReadFloat();
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
Пример #21
0
 /*
  * Reads the information from the index and data files.
  *
  * @param index holds the sprite indices
  * @param data  holds the sprite data per index
  * @throws IOException
  */
 public void readValues(DataInputStream index, DataInputStream data)
 {
     do
     {
         int opCode = data.ReadByte();
         if (opCode == 0)
         {
             break;
         }
         if (opCode == 1)
         {
             id = data.ReadShort();
         }
         else if (opCode == 2)
         {
             name = data.ReadUTF();
         }
         else if (opCode == 3)
         {
             drawOffsetX = data.ReadShort();
         }
         else if (opCode == 4)
         {
             drawOffsetY = data.ReadShort();
         }
         else if (opCode == 5)
         {
             int    indexLength = index.ReadInt();
             byte[] dataread    = new byte[indexLength];
             data.Read(dataread, 0, indexLength);
             spriteData = dataread;
         }
     } while (true);
 }
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._parameterTypeDesignator = dis.ReadUnsignedByte();
                    this._changeIndicator         = dis.ReadUnsignedByte();
                    this._partAttachedTo          = dis.ReadUnsignedShort();
                    this._parameterType           = dis.ReadInt();
                    this._parameterValue          = dis.ReadDouble();
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Пример #23
0
        internal static void CheckIsPreview(InputStream classInputStream)
        {
            if (classInputStream == null)
            {
                throw new InvalidOperationException("Bytecode not available, can't check class version"
                                                    );
            }
            int minorVersion;

            try
            {
                using (var callerClassStream = new DataInputStream(classInputStream))
                {
                    callerClassStream.ReadInt();
                    minorVersion = callerClassStream.ReadUnsignedShort();
                }
            }
            catch (IOException ioe)
            {
                throw new InvalidOperationException("I/O error, can't check class version", ioe);
            }

            if (minorVersion != 0xFFFF)
            {
                throw new InvalidOperationException(
                          "ASM8_EXPERIMENTAL can only be used by classes compiled with --enable-preview"
                          );
            }
        }
Пример #24
0
            /// <summary>Read an integer of this type from the given input stream</summary>
            /// <exception cref="System.IO.IOException"/>
            public int Read(DataInputStream @in)
            {
                switch (this)
                {
                case VectorMap.Itype.Int8:
                {
                    return(@in.ReadByte());
                }

                case VectorMap.Itype.Int16:
                {
                    return(@in.ReadShort());
                }

                case VectorMap.Itype.Int32:
                {
                    return(@in.ReadInt());
                }

                default:
                {
                    throw new Exception("Unknown itype: " + this);
                }
                }
            }
Пример #25
0
        public void read(DataInputStream dai, bool oldVersion)
        {
            int v = dai.ReadInt();

            if (v == 1)
            {
                long l = dai.ReadLong();
                refTime = l == -1 ? null : new Time(l);
                for (int i = 0; i < 3; i++)
                {
                    ecef.set(i, dai.ReadDouble());
                }
                for (int i = 0; i < 3; i++)
                {
                    enu.set(i, dai.ReadDouble());
                }
                for (int i = 0; i < 3; i++)
                {
                    geod.set(i, dai.ReadDouble());
                }
            }
            else
            {
                throw new IOException("Unknown format version:" + v);
            }
        }
Пример #26
0
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._hour         = dis.ReadInt();
                    this._timePastHour = dis.ReadUnsignedInt();
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Пример #27
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._munitionID.Unmarshal(dis);
                    this._eventID.Unmarshal(dis);
                    this._fireMissionIndex = dis.ReadInt();
                    this._locationInWorldCoordinates.Unmarshal(dis);
                    this._burstDescriptor.Unmarshal(dis);
                    this._velocity.Unmarshal(dis);
                    this._range = dis.ReadFloat();
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Пример #28
0
        /// <exception cref="System.IO.IOException"/>
        public static double[] ReadDoubleArr(DataInputStream rf)
        {
            int size = rf.ReadInt();

            byte[] b = new byte[8 * size];
            rf.Read(b);
            return(ByteArrToDoubleArr(b));
        }
Пример #29
0
        /// <exception cref="System.IO.IOException"/>
        public static float[] ReadFloatArr(DataInputStream rf)
        {
            int size = rf.ReadInt();

            byte[] b = new byte[4 * size];
            rf.Read(b);
            return(ByteArrToFloatArr(b));
        }
Пример #30
0
        private void HandleEndSession(DataInputStream dataInputStream, model.RtpMidiServer rtpMidiServer)
        {
            int protocolVersion = dataInputStream.ReadInt();

            if (protocolVersion != PROTOCOL_VERSION)
            {
                Log.Info("RtpMidi", "Protocol version: {} did not match version {}", protocolVersion, PROTOCOL_VERSION);
                return;
            }
            int initiatorToken = dataInputStream.ReadInt();
            int ssrc           = dataInputStream.ReadInt();

            foreach (IRtpMidiCommandListener listener in listeners)
            {
                listener.OnEndSession(new RtpMidiEndSession(protocolVersion, initiatorToken, ssrc), rtpMidiServer);
            }
        }