InputStreamImpl.java 1.62 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.internal.io.stream;

import com.adobe.internal.io.stream.InputByteStream;
import java.io.IOException;
import java.io.InputStream;

class InputStreamImpl
extends InputStream {
    InputByteStream ibs;
    protected long mark = 0;

    public InputStreamImpl(InputByteStream ibs) {
        this.ibs = ibs;
    }

    @Override
    public int available() throws IOException {
        return (int)(this.ibs.bytesAvailable() <= Integer.MAX_VALUE ? this.ibs.bytesAvailable() : Integer.MAX_VALUE);
    }

    @Override
    public void mark(int readLimit) {
        try {
            this.mark = this.ibs.getPosition();
        }
        catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public boolean markSupported() {
        return true;
    }

    @Override
    public void reset() throws IOException {
        this.ibs.seek(this.mark);
    }

    @Override
    public long skip(long n) throws IOException {
        n = Math.min(n, this.ibs.length());
        this.ibs.seek(this.ibs.getPosition() + n);
        return n;
    }

    @Override
    public void close() throws IOException {
        if (this.ibs != null) {
            this.ibs.close();
            this.ibs = null;
        }
    }

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

    @Override
    public int read(byte[] b, int offset, int length) throws IOException {
        return this.ibs.read(b, offset, length);
    }

    @Override
    public int read(byte[] b) throws IOException {
        return this.read(b, 0, b.length);
    }
}