Package com.caucho.vfs

Examples of com.caucho.vfs.TempBuffer


   * Append from an input stream, using InputStream semantics, i.e
   * call is.read() only once.
   */
  public int appendRead(BinaryInput is, long length)
  {
    TempBuffer tBuf = TempBuffer.allocate();

    try {
      byte []buffer = tBuf.getBuffer();
      int sublen = buffer.length;
      if (length < sublen)
        sublen = (int) length;
      else if (length > sublen) {
        buffer = new byte[(int) length];
View Full Code Here


   * Append from an input stream, reading all available data from the
   * stream.
   */
  public int appendReadAll(BinaryInput is, long length)
  {
    TempBuffer tBuf = TempBuffer.allocate();

    try {
      byte []buffer = tBuf.getBuffer();
      int readLength = 0;
     
      while (length > 0) {
        int sublen = buffer.length;
        if (length < sublen)
View Full Code Here

    if (this == o)
      return true;
    else if ((o instanceof TempBufferBytesValue)) {
      TempBufferBytesValue tb = (TempBufferBytesValue) o;

      TempBuffer ptrA = _head;
      TempBuffer ptrB = tb._head;
     
      while (ptrA != null && ptrB != null) {
        byte []bufferA = ptrA.getBuffer();
        int lengthA = ptrA.getLength();
       
        byte []bufferB = ptrB.getBuffer();
        int lengthB = ptrB.getLength();

        if (lengthA != lengthB)
          return false;

        while (--lengthA >= 0) {
          if (bufferA[lengthA] != bufferB[lengthA])
            return false;
        }

        ptrA = ptrA.getNext();
        ptrB = ptrB.getNext();
      }

      return ptrA == null && ptrB == null;
    }
    else
View Full Code Here

  public static Value socket_read(Env env,
                                  @NotNull SocketInputOutput socket,
                                  int length, @Optional int type)
  {
    TempBuffer tempBuffer = null;
    TempCharBuffer tempCharBuffer = null;

    try {
      if (type == PHP_NORMAL_READ) {
        return socket.readLine(length);
      } else {
        tempBuffer = TempBuffer.allocate();

        if (length > tempBuffer.getCapacity())
          length = tempBuffer.getCapacity();

        byte []buffer = tempBuffer.getBuffer();

        length = socket.read(buffer, 0, length);

        if (length > 0) {
          StringValue sb = env.createBinaryBuilder(buffer, 0, length);
View Full Code Here

          if (length <= 0)
            length = -1;
        }

        if (length < 0) {
          TempBuffer tempBuffer = TempBuffer.allocate();

          try {
            byte[] bytes = new byte[1024];

            int len;

            while ((len = inputStream.read(bytes, 0, 1024)) != -1)
              tempBuffer.write(bytes, 0, len);
          }
          catch (IOException ex) {
            _error.error(ex);
            return false;
          }

          TempReadStream tempReadStream = new TempReadStream(tempBuffer);
          tempReadStream.setFreeWhenDone(true);

          _preparedStatement.setBinaryStream(index, new ReadStream(tempReadStream), tempBuffer.getLength());
        }
        else
          _preparedStatement.setBinaryStream(index, inputStream, (int) length);
      }
    }
View Full Code Here

        return -1;

      if (out == null)
        return -1;

      TempBuffer temp = TempBuffer.allocate();
      byte []buffer = temp.getBuffer();

      while (offset-- > 0)
        in.read();

      if (length < 0)
View Full Code Here

   * Prints out the remaining data in the stream to stdout
   */
  public Value gzpassthru(Env env, @NotNull BinaryInput is)
  {
    WriteStream out = env.getOut();
    TempBuffer tempBuf = TempBuffer.allocate();
    byte[] buffer = tempBuf.getBuffer();

    int length = 0;
    try {
      int sublen = is.read(buffer, 0, buffer.length);
      while (sublen > 0) {
View Full Code Here

   */
  public Value gzcompress(Env env,
                          InputStream data,
                          @Optional("6") int level)
  {
    TempBuffer tempBuf = TempBuffer.allocate();
    byte []buffer = tempBuf.getBuffer();

    Deflater deflater = null;
   
    try {
      deflater = new Deflater(level, true);
View Full Code Here

   */
  public Value gzuncompress(Env env,
                            InputStream is,
                            @Optional("0") long length)
  {
    TempBuffer tempBuf = TempBuffer.allocate();
    byte []buffer = tempBuf.getBuffer();

    InflaterInputStream in = null;
    try {
      if (length == 0)
        length = Long.MAX_VALUE;
View Full Code Here

   * @return compressed using DEFLATE algorithm
   */
  public Value gzdeflate(Env env, InputStream data,
                         @Optional("6") int level)
  {
    TempBuffer tempBuf = TempBuffer.allocate();
    byte []buffer = tempBuf.getBuffer();
    Deflater deflater = null;
   
    try {
      deflater = new Deflater(level, true);

View Full Code Here

TOP

Related Classes of com.caucho.vfs.TempBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.