FileOperator.smali
.class final Lokhttp3/internal/cache2/FileOperator;
.super Ljava/lang/Object;
# static fields
.field private static final BUFFER_SIZE:I = 0x2000
# instance fields
.field private final byteArray:[B
.field private final byteBuffer:Ljava/nio/ByteBuffer;
.field private final fileChannel:Ljava/nio/channels/FileChannel;
# direct methods
.method public constructor <init>(Ljava/nio/channels/FileChannel;)V
.registers 3
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const/16 v0, 0x2000
new-array v0, v0, [B
iput-object v0, p0, Lokhttp3/internal/cache2/FileOperator;->byteArray:[B
iget-object v0, p0, Lokhttp3/internal/cache2/FileOperator;->byteArray:[B
invoke-static {v0}, Ljava/nio/ByteBuffer;->wrap([B)Ljava/nio/ByteBuffer;
move-result-object v0
iput-object v0, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
iput-object p1, p0, Lokhttp3/internal/cache2/FileOperator;->fileChannel:Ljava/nio/channels/FileChannel;
return-void
.end method
# virtual methods
.method public read(JLokio/c;J)V
.registers 12
const-wide/16 v4, 0x0
cmp-long v0, p4, v4
if-gez v0, :cond_21
new-instance v0, Ljava/lang/IndexOutOfBoundsException;
invoke-direct {v0}, Ljava/lang/IndexOutOfBoundsException;-><init>()V
throw v0
:cond_c
:try_start_c
iget-object v0, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v0}, Ljava/nio/ByteBuffer;->position()I
move-result v0
iget-object v1, p0, Lokhttp3/internal/cache2/FileOperator;->byteArray:[B
const/4 v2, 0x0
invoke-virtual {p3, v1, v2, v0}, Lokio/c;->b([BII)Lokio/c;
:try_end_18
.catchall {:try_start_c .. :try_end_18} :catchall_42
int-to-long v2, v0
add-long/2addr p1, v2
int-to-long v0, v0
sub-long/2addr p4, v0
iget-object v0, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v0}, Ljava/nio/ByteBuffer;->clear()Ljava/nio/Buffer;
:cond_21
cmp-long v0, p4, v4
if-lez v0, :cond_49
:try_start_25
iget-object v0, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
const-wide/16 v2, 0x2000
invoke-static {v2, v3, p4, p5}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
long-to-int v1, v2
invoke-virtual {v0, v1}, Ljava/nio/ByteBuffer;->limit(I)Ljava/nio/Buffer;
iget-object v0, p0, Lokhttp3/internal/cache2/FileOperator;->fileChannel:Ljava/nio/channels/FileChannel;
iget-object v1, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v0, v1, p1, p2}, Ljava/nio/channels/FileChannel;->read(Ljava/nio/ByteBuffer;J)I
move-result v0
const/4 v1, -0x1
if-ne v0, v1, :cond_c
new-instance v0, Ljava/io/EOFException;
invoke-direct {v0}, Ljava/io/EOFException;-><init>()V
throw v0
:try_end_42
.catchall {:try_start_25 .. :try_end_42} :catchall_42
:catchall_42
move-exception v0
iget-object v1, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v1}, Ljava/nio/ByteBuffer;->clear()Ljava/nio/Buffer;
throw v0
:cond_49
return-void
.end method
.method public write(JLokio/c;J)V
.registers 14
const-wide/16 v6, 0x0
cmp-long v0, p4, v6
if-ltz v0, :cond_e
invoke-virtual {p3}, Lokio/c;->a()J
move-result-wide v0
cmp-long v0, p4, v0
if-lez v0, :cond_4c
:cond_e
new-instance v0, Ljava/lang/IndexOutOfBoundsException;
invoke-direct {v0}, Ljava/lang/IndexOutOfBoundsException;-><init>()V
throw v0
:goto_14
cmp-long v2, p4, v6
if-lez v2, :cond_4b
const-wide/16 v2, 0x2000
:try_start_1a
invoke-static {v2, v3, p4, p5}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
long-to-int v2, v2
iget-object v3, p0, Lokhttp3/internal/cache2/FileOperator;->byteArray:[B
const/4 v4, 0x0
invoke-virtual {p3, v3, v4, v2}, Lokio/c;->a([BII)I
iget-object v3, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v3, v2}, Ljava/nio/ByteBuffer;->limit(I)Ljava/nio/Buffer;
:cond_2a
iget-object v3, p0, Lokhttp3/internal/cache2/FileOperator;->fileChannel:Ljava/nio/channels/FileChannel;
iget-object v4, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v3, v4, v0, v1}, Ljava/nio/channels/FileChannel;->write(Ljava/nio/ByteBuffer;J)I
move-result v3
int-to-long v4, v3
add-long/2addr v0, v4
iget-object v3, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v3}, Ljava/nio/ByteBuffer;->hasRemaining()Z
:try_end_39
.catchall {:try_start_1a .. :try_end_39} :catchall_44
move-result v3
if-nez v3, :cond_2a
int-to-long v2, v2
sub-long/2addr p4, v2
iget-object v2, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v2}, Ljava/nio/ByteBuffer;->clear()Ljava/nio/Buffer;
goto :goto_14
:catchall_44
move-exception v0
iget-object v1, p0, Lokhttp3/internal/cache2/FileOperator;->byteBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v1}, Ljava/nio/ByteBuffer;->clear()Ljava/nio/Buffer;
throw v0
:cond_4b
return-void
:cond_4c
move-wide v0, p1
goto :goto_14
.end method