Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/InflaterDataAccess.java @ 420:6c22bdc0bdfd
Respect long offsets in revlogs
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 22 Mar 2012 22:56:01 +0100 |
parents | fdc1db8f7f61 |
children | fdd7d756dea0 |
comparison
equal
deleted
inserted
replaced
419:7f136a3fa671 | 420:6c22bdc0bdfd |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 TMate Software Ltd | 2 * Copyright (c) 2011-2012 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
38 private final byte[] buffer; | 38 private final byte[] buffer; |
39 private final byte[] singleByte = new byte[1]; | 39 private final byte[] singleByte = new byte[1]; |
40 private int decompressedPos = 0; | 40 private int decompressedPos = 0; |
41 private int decompressedLength; | 41 private int decompressedLength; |
42 | 42 |
43 public InflaterDataAccess(DataAccess dataAccess, int offset, int compressedLength) { | 43 public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength) { |
44 this(dataAccess, offset, compressedLength, -1, new Inflater(), new byte[512]); | 44 this(dataAccess, offset, compressedLength, -1, new Inflater(), new byte[512]); |
45 } | 45 } |
46 | 46 |
47 public InflaterDataAccess(DataAccess dataAccess, int offset, int compressedLength, int actualLength) { | 47 public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength, int actualLength) { |
48 this(dataAccess, offset, compressedLength, actualLength, new Inflater(), new byte[512]); | 48 this(dataAccess, offset, compressedLength, actualLength, new Inflater(), new byte[512]); |
49 } | 49 } |
50 | 50 |
51 public InflaterDataAccess(DataAccess dataAccess, int offset, int compressedLength, int actualLength, Inflater inflater, byte[] buf) { | 51 public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength, int actualLength, Inflater inflater, byte[] buf) { |
52 super(dataAccess, offset, compressedLength); | 52 super(dataAccess, offset, compressedLength); |
53 if (inflater == null || buf == null) { | 53 if (inflater == null || buf == null) { |
54 throw new IllegalArgumentException(); | 54 throw new IllegalArgumentException(); |
55 } | 55 } |
56 this.inflater = inflater; | 56 this.inflater = inflater; |
117 public void seek(int localOffset) throws IOException { | 117 public void seek(int localOffset) throws IOException { |
118 if (localOffset < 0 /* || localOffset >= length() */) { | 118 if (localOffset < 0 /* || localOffset >= length() */) { |
119 throw new IllegalArgumentException(); | 119 throw new IllegalArgumentException(); |
120 } | 120 } |
121 if (localOffset >= decompressedPos) { | 121 if (localOffset >= decompressedPos) { |
122 skip((int) (localOffset - decompressedPos)); | 122 skip(localOffset - decompressedPos); |
123 } else { | 123 } else { |
124 reset(); | 124 reset(); |
125 skip((int) localOffset); | 125 skip(localOffset); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 @Override | 129 @Override |
130 public void skip(final int bytesToSkip) throws IOException { | 130 public void skip(final int bytesToSkip) throws IOException { |