GzipSink.java 2.9 KB
package okio;

import java.io.IOException;
import java.util.zip.CRC32;
import java.util.zip.Deflater;
import tx;
import ua;

public final class GzipSink
  implements Sink
{
  private final BufferedSink a;
  private final Deflater b;
  private final DeflaterSink c;
  private boolean d;
  private final CRC32 e = new CRC32();
  
  public GzipSink(Sink paramSink)
  {
    if (paramSink == null) {
      throw new IllegalArgumentException("sink == null");
    }
    this.b = new Deflater(-1, true);
    this.a = Okio.buffer(paramSink);
    this.c = new DeflaterSink(this.a, this.b);
    paramSink = this.a.buffer();
    paramSink.writeShort(8075);
    paramSink.writeByte(8);
    paramSink.writeByte(0);
    paramSink.writeInt(0);
    paramSink.writeByte(0);
    paramSink.writeByte(0);
  }
  
  private void a(Buffer paramBuffer, long paramLong)
  {
    for (paramBuffer = paramBuffer.a; paramLong > 0L; paramBuffer = paramBuffer.f)
    {
      int i = (int)Math.min(paramLong, paramBuffer.c - paramBuffer.b);
      this.e.update(paramBuffer.a, paramBuffer.b, i);
      paramLong -= i;
    }
  }
  
  public final void close()
    throws IOException
  {
    if (this.d) {}
    for (;;)
    {
      return;
      Object localObject2 = null;
      try
      {
        this.c.a();
        this.a.writeIntLe((int)this.e.getValue());
        this.a.writeIntLe(this.b.getTotalIn());
        try
        {
          this.b.end();
          localObject1 = localObject2;
        }
        catch (Throwable localThrowable1)
        {
          for (;;)
          {
            Object localObject1;
            label72:
            if (localThrowable3 != null) {
              localThrowable2 = localThrowable3;
            }
          }
        }
        try
        {
          this.a.close();
          localObject2 = localObject1;
        }
        catch (Throwable localThrowable4)
        {
          Object localObject3 = localThrowable2;
          if (localThrowable2 != null) {
            break label72;
          }
          localObject3 = localThrowable4;
          break label72;
        }
        this.d = true;
        if (localObject2 == null) {
          continue;
        }
        ua.a((Throwable)localObject2);
        return;
      }
      catch (Throwable localThrowable3)
      {
        for (;;) {}
      }
    }
  }
  
  public final void flush()
    throws IOException
  {
    this.c.flush();
  }
  
  public final Timeout timeout()
  {
    return this.a.timeout();
  }
  
  public final void write(Buffer paramBuffer, long paramLong)
    throws IOException
  {
    if (paramLong < 0L) {
      throw new IllegalArgumentException("byteCount < 0: " + paramLong);
    }
    if (paramLong == 0L) {
      return;
    }
    a(paramBuffer, paramLong);
    this.c.write(paramBuffer, paramLong);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/okio/GzipSink.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */