示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void write(java.io.OutputStream out) throws java.io.IOException
        public virtual void write(System.IO.Stream @out)
        {
            DataOutputStream data = new DataOutputStream(@out);

            data.writeInt(packetSize);
            data.writeInt(address);
            data.writeInt(Length);

            if (buffer is ByteBuffer)
            {
                WritableByteChannel channel = Channels.newChannel(@out);
                channel.write((ByteBuffer)buffer);
            }
            else
            {
                IMemoryReader reader = MemoryReader.getMemoryReader(address, Length, 1);
                for (int i = 0; i < Length; i++)
                {
                    data.writeByte(reader.readNext());
                }
            }

            VideoEngine.log_Renamed.info(string.Format("Saved memory {0:x8} - {1:x8} (len {2:x8})", address, address + Length, Length));
            //VideoEngine.Console.WriteLine("CaptureRAM write " + ((3 * 4) + Length));

            //data.flush();
            //out.flush();
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void write(byte[] data) throws java.io.IOException
        public override void Write(sbyte[] data)
        {
            ByteBuffer buffer = ByteBuffer.wrap(data);

            while (buffer.hasRemaining())
            {
                _writableByteChannel.write(buffer);
            }
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public BufferedChannelOutput flush() throws java.io.IOException
        public override BufferedChannelOutput Flush()
        {
            _buffer.flip();
            do
            {
                _channel.write(_buffer);
            } while (_buffer.remaining() > 0);
            _buffer.clear();
            return(this);
        }
示例#4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void fastCopy(java.io.InputStream paramInputStream, java.io.OutputStream paramOutputStream) throws java.io.IOException
        public static void fastCopy(Stream paramInputStream, Stream paramOutputStream)
        {
            ReadableByteChannel readableByteChannel = Channels.newChannel(paramInputStream);
            WritableByteChannel writableByteChannel = Channels.newChannel(paramOutputStream);
            ByteBuffer          byteBuffer          = ByteBuffer.allocateDirect(16384);

            while (readableByteChannel.read(byteBuffer) != -1)
            {
                byteBuffer.flip();
                writableByteChannel.write(byteBuffer);
                byteBuffer.compact();
            }
            byteBuffer.flip();
            while (byteBuffer.hasRemaining())
            {
                writableByteChannel.write(byteBuffer);
            }
            readableByteChannel.close();
            writableByteChannel.close();
        }
示例#5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void generateFileWithRecords(java.nio.channels.WritableByteChannel channel, int recordCount, int recordSize) throws java.io.IOException
        protected internal virtual void GenerateFileWithRecords(WritableByteChannel channel, int recordCount, int recordSize)
        {
            ByteBuffer buf = ByteBuffer.allocate(recordSize);

            for (int i = 0; i < recordCount; i++)
            {
                GenerateRecordForId(i, buf);
                int rem = buf.remaining();
                do
                {
                    rem -= channel.write(buf);
                } while (rem > 0);
            }
        }
示例#6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long writeData(java.nio.channels.ReadableByteChannel data, ByteBuffer temporaryBuffer, boolean hasData, java.nio.channels.WritableByteChannel channel) throws java.io.IOException
        private long WriteData(ReadableByteChannel data, ByteBuffer temporaryBuffer, bool hasData, WritableByteChannel channel)
        {
            long totalToWrite = 0;
            long totalWritten = 0;

            if (hasData)
            {
                while (data.read(temporaryBuffer) >= 0)
                {
                    temporaryBuffer.flip();
                    totalToWrite += temporaryBuffer.limit();
                    int bytesWritten;
                    while ((totalWritten += bytesWritten = channel.write(temporaryBuffer)) < totalToWrite)
                    {
                        if (bytesWritten < 0)
                        {
                            throw new IOException("Unable to write to disk, reported bytes written was " + bytesWritten);
                        }
                    }
                    temporaryBuffer.clear();
                }
            }
            return(totalWritten);
        }