private int read(long pos, byte[] dst, int off, int len) throws IOException { if (len == 0) return 0; int cnt = 0; while (0 < len) { int r = out.read(pos, ByteBuffer.wrap(dst, off, len)); if (r <= 0) break; pos += r; off += r; len -= r; cnt += r; } return cnt != 0 ? cnt : -1; }
private DfsBlock getOrLoadBlock(long pos) throws IOException { long s = toBlockStart(pos); DfsBlock b = cache.get(packKey, s); if (b != null) return b; byte[] d = new byte[blockSize]; for (int p = 0; p < blockSize;) { int n = out.read(s + p, ByteBuffer.wrap(d, p, blockSize - p)); if (n <= 0) throw new EOFException(JGitText.get().unexpectedEofInPack); p += n; } b = new DfsBlock(packKey, s, d); cache.put(b); return b; }
private int read(long pos, byte[] dst, int off, int len) throws IOException { if (len == 0) return 0; int cnt = 0; while (0 < len) { int r = out.read(pos, ByteBuffer.wrap(dst, off, len)); if (r <= 0) break; pos += r; off += r; len -= r; cnt += r; } return cnt != 0 ? cnt : -1; }
private int read(long pos, byte[] dst, int off, int len) throws IOException { if (len == 0) return 0; int cnt = 0; while (0 < len) { int r = out.read(pos, ByteBuffer.wrap(dst, off, len)); if (r <= 0) break; pos += r; off += r; len -= r; cnt += r; } return cnt != 0 ? cnt : -1; }
private DfsBlock getOrLoadBlock(long pos) throws IOException { long s = toBlockStart(pos); DfsBlock b = cache.get(packKey, s); if (b != null) return b; byte[] d = new byte[blockSize]; for (int p = 0; p < blockSize;) { int n = out.read(s + p, ByteBuffer.wrap(d, p, blockSize - p)); if (n <= 0) throw new EOFException(JGitText.get().unexpectedEofInPack); p += n; } b = new DfsBlock(packKey, s, d); cache.put(b); return b; }
private DfsBlock getOrLoadBlock(long pos) throws IOException { long s = toBlockStart(pos); DfsBlock b = cache.get(packKey, s); if (b != null) return b; byte[] d = new byte[blockSize]; for (int p = 0; p < blockSize;) { int n = out.read(s + p, ByteBuffer.wrap(d, p, blockSize - p)); if (n <= 0) throw new EOFException(DfsText.get().unexpectedEofInPack); p += n; } b = new DfsBlock(packKey, s, d); cache.put(b); return b; }