summaryrefslogtreecommitdiff
path: root/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/junrar/io/InputStreamReadOnlyAccessFile.java
blob: 84602aebfb57f7ab2e9df417c6a412eff34c5319 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.fox.ttcomics2.junrar.io;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;


public class InputStreamReadOnlyAccessFile implements IReadOnlyAccess {
    private RandomAccessStream is;

    public InputStreamReadOnlyAccessFile(final InputStream is) {
        this.is = new RandomAccessStream(new BufferedInputStream(is));
    }

    @Override
    public long getPosition() throws IOException {
        return is.getLongFilePointer();
    }

    @Override
    public void setPosition(long pos) throws IOException {
        is.seek(pos);
    }

    @Override
    public int read() throws IOException {
        return is.read();
    }

    @Override
    public int read(byte[] buffer, int off, int count) throws IOException {
        return is.read(buffer, off, count);
    }

    @Override
    public int readFully(byte[] buffer, int count) throws IOException {
        is.readFully(buffer, count);
        return count;
    }

    @Override
    public void close() throws IOException {
        is.close();
    }

}