Ignore:
Timestamp:
2017-10-30T22:46:09+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #15505 - update to metadata-extractor 2.10.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/lang/StreamReader.java

    r10862 r13061  
    11/*
    2  * Copyright 2002-2016 Drew Noakes
     2 * Copyright 2002-2017 Drew Noakes
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    3737    private final InputStream _stream;
    3838
     39    private long _pos;
     40
     41    @Override
     42    public long getPosition()
     43    {
     44        return _pos;
     45    }
     46
     47    @SuppressWarnings("ConstantConditions")
    3948    public StreamReader(@NotNull InputStream stream)
    4049    {
     
    4352
    4453        _stream = stream;
     54        _pos = 0;
    4555    }
    4656
    4757    @Override
    48     protected byte getByte() throws IOException
     58    public byte getByte() throws IOException
    4959    {
    5060        int value = _stream.read();
    5161        if (value == -1)
    5262            throw new EOFException("End of data reached.");
     63        _pos++;
    5364        return (byte)value;
    5465    }
     
    5970    {
    6071        byte[] bytes = new byte[count];
     72        getBytes(bytes, 0, count);
     73        return bytes;
     74    }
     75
     76    @Override
     77    public void getBytes(@NotNull byte[] buffer, int offset, int count) throws IOException
     78    {
    6179        int totalBytesRead = 0;
    62 
    63         while (totalBytesRead != count) {
    64             final int bytesRead = _stream.read(bytes, totalBytesRead, count - totalBytesRead);
     80        while (totalBytesRead != count)
     81        {
     82            final int bytesRead = _stream.read(buffer, offset + totalBytesRead, count - totalBytesRead);
    6583            if (bytesRead == -1)
    6684                throw new EOFException("End of data reached.");
     
    6886            assert(totalBytesRead <= count);
    6987        }
    70 
    71         return bytes;
     88        _pos += totalBytesRead;
    7289    }
    7390
     
    93110    }
    94111
     112    @Override
     113    public int available() {
     114        try {
     115            return _stream.available();
     116        } catch (IOException e) {
     117            return 0;
     118        }
     119    }
     120
    95121    private long skipInternal(long n) throws IOException
    96122    {
     
    109135                break;
    110136        }
     137        _pos += skippedTotal;
    111138        return skippedTotal;
    112139    }
Note: See TracChangeset for help on using the changeset viewer.