private long readRevisionFromReportFile() throws IOException { if (read() == '+') { return readNumberFromReportFile(); } return SVNRepository.INVALID_REVISION; }
public PathInfo readPathInfoFromReportFile() throws IOException { int firstByte = read(); if (firstByte == -1 || firstByte == '-') { return null; } String path = readStringFromReportFile(); String linkPath = read() == '+' ? readStringFromReportFile() : null; long revision = readRevisionFromReportFile(); boolean startEmpty = read() == '+' ? true : false; String lockToken = read() == '+' ? readStringFromReportFile() : null; return new PathInfo(path, linkPath, lockToken, revision, startEmpty); }
private int readNumberFromReportFile() throws IOException { int b; ByteArrayOutputStream resultStream = new ByteArrayOutputStream(); while ((b = read()) != ':') { resultStream.write(b); } return Integer.parseInt(new String(resultStream.toByteArray(), "UTF-8"), 10); }
private long readRevisionFromReportFile() throws IOException { if (read() == '+') { return readNumberFromReportFile(); } return FSRepository.SVN_INVALID_REVNUM; }
private int readNumberFromReportFile() throws IOException { int b; ByteArrayOutputStream resultStream = new ByteArrayOutputStream(); while ((b = read()) != ':') { resultStream.write(b); } return Integer.parseInt(new String(resultStream.toByteArray(), "UTF-8"), 10); }
private long readRevisionFromReportFile() throws IOException { if (read() == '+') { return readNumberFromReportFile(); } return SVNRepository.INVALID_REVISION; }
private int readNumberFromReportFile() throws IOException { int b; ByteArrayOutputStream resultStream = new ByteArrayOutputStream(); while ((b = read()) != ':') { resultStream.write(b); } return Integer.parseInt(new String(resultStream.toByteArray(), "UTF-8"), 10); }
private long readRevisionFromReportFile() throws IOException { if (read() == '+') { return readNumberFromReportFile(); } return SVNRepository.INVALID_REVISION; }
private int readNumberFromReportFile() throws IOException { int b; ByteArrayOutputStream resultStream = new ByteArrayOutputStream(); while ((b = read()) != ':') { resultStream.write(b); } return Integer.parseInt(new String(resultStream.toByteArray(), "UTF-8"), 10); }
private String readStringFromReportFile() throws IOException { int length = readNumberFromReportFile(); if (length == 0) { return ""; } byte[] buffer = new byte[length]; read(buffer, 0, length); return new String(buffer, "UTF-8"); }
public String readLine(StringBuffer buffer) throws SVNException { if (buffer == null) { buffer = new StringBuffer(); } boolean endOfLineMet = false; try { while (!endOfLineMet) { allocateReadBuffer(160); while(myReadLineBuffer.hasRemaining()) { int b = read(); if (b < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.STREAM_UNEXPECTED_EOF, "Can''t read length line from file {0}", getFile()); SVNErrorManager.error(err); } else if (b == '\n') { endOfLineMet = true; break; } myReadLineBuffer.put((byte) (b & 0XFF)); } myReadLineBuffer.flip(); buffer.append(myDecoder.decode(myReadLineBuffer).toString()); } } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_CORRUPT, "Can''t read length line from file {0}: {1}", new Object[]{getFile(), e.getLocalizedMessage()}); SVNErrorManager.error(err, e); } return buffer.toString(); }
private String readStringFromReportFile() throws IOException { int length = readNumberFromReportFile(); if (length == 0) { return ""; } byte[] buffer = new byte[length]; read(buffer, 0, length); return new String(buffer, "UTF-8"); }
public String readLine(int limit) throws SVNException { allocateReadBuffer(limit); try { while(myReadLineBuffer.hasRemaining()) { int b = read(); if (b < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.STREAM_UNEXPECTED_EOF, "Can''t read length line from file {0}", getFile()); SVNErrorManager.error(err); } else if (b == '\n') { break; } myReadLineBuffer.put((byte) (b & 0XFF)); } myReadLineBuffer.flip(); return myDecoder.decode(myReadLineBuffer).toString(); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_CORRUPT, "Can''t read length line from file {0}: {1}", new Object[]{getFile(), e.getLocalizedMessage()}); SVNErrorManager.error(err, e); } return null; }
private String readStringFromReportFile() throws IOException { int length = readNumberFromReportFile(); if (length == 0) { return ""; } byte[] buffer = new byte[length]; read(buffer, 0, length); return new String(buffer, "UTF-8"); }
public String readLine(int limit) throws SVNException { allocateReadBuffer(limit); try { while(myReadLineBuffer.hasRemaining()) { int b = read(); if (b < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.STREAM_UNEXPECTED_EOF, "Can''t read length line from file {0}", getFile()); SVNErrorManager.error(err, SVNLogType.DEFAULT); } else if (b == '\n') { break; } myReadLineBuffer.put((byte) (b & 0XFF)); } myReadLineBuffer.flip(); return myDecoder.decode(myReadLineBuffer).toString(); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_CORRUPT, "Can''t read length line from file {0}: {1}", new Object[]{getFile(), e.getLocalizedMessage()}); SVNErrorManager.error(err, e, SVNLogType.DEFAULT); } return null; }
private String readStringFromReportFile() throws IOException { int length = readNumberFromReportFile(); if (length == 0) { return ""; } byte[] buffer = new byte[length]; read(buffer, 0, length); return new String(buffer, "UTF-8"); }
public String readLine(int limit) throws SVNException { allocateReadBuffer(limit); try { while(myReadLineBuffer.hasRemaining()) { int b = read(); if (b < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.STREAM_UNEXPECTED_EOF, "Can''t read length line from file {0}", getFile()); SVNErrorManager.error(err, SVNLogType.DEFAULT); } else if (b == '\n') { break; } myReadLineBuffer.put((byte) (b & 0XFF)); } myReadLineBuffer.flip(); return myDecoder.decode(myReadLineBuffer).toString(); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_CORRUPT, "Can''t read length line from file {0}: {1}", new Object[]{getFile(), e.getLocalizedMessage()}); SVNErrorManager.error(err, e, SVNLogType.DEFAULT); } return null; }
public String readLine(int limit) throws SVNException { long currentLimit = limit < 0 ? 1024 : limit; //if limit < 0, read line buffer should have infinite size allocateReadBuffer((int) currentLimit); try { while(myReadLineBuffer.hasRemaining()) { int b = read(); if (b < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.STREAM_UNEXPECTED_EOF, "Can''t read length line from file {0}", getFile()); SVNErrorManager.error(err, SVNLogType.DEFAULT); } else if (b == '\n') { break; } myReadLineBuffer.put((byte) (b & 0XFF)); if (limit < 0 && !myReadLineBuffer.hasRemaining()) { //make myReadLineBuffer twice as larger byte[] oldArray = myReadLineBuffer.array(); int oldLimit = (int) currentLimit; currentLimit = currentLimit * 2; allocateReadBuffer((int) currentLimit); myReadLineBuffer.put(oldArray, 0, oldLimit); } } myReadLineBuffer.flip(); return myDecoder.decode(myReadLineBuffer).toString(); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_CORRUPT, "Can''t read length line from file {0}: {1}", new Object[]{getFile(), e.getLocalizedMessage()}); SVNErrorManager.error(err, e, SVNLogType.DEFAULT); } return null; }
public void ensureFooterLoaded() throws SVNException { try { if (myL2POffset == -1) { long fileSize = size(); seek(fileSize - 1); int footerSize = read() & 0xff; long footerOffset = fileSize - 1 - footerSize; if (footerOffset < 0 || footerOffset >= fileSize) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.FS_CORRUPT, "Invalid footer size {0}", String.valueOf(footerSize)); SVNErrorManager.error(errorMessage, SVNLogType.FSFS); } seek(footerOffset); byte[] footerBytes = new byte[footerSize]; int bytesRead = read(footerBytes, 0, footerBytes.length); assert bytesRead == footerBytes.length; parseFooter(new String(footerBytes)); myFooterOffset = footerOffset; }//otherwise do nothing, it is already loaded } catch (IOException e) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e); SVNErrorManager.error(errorMessage, SVNLogType.FSFS); } }
private FSPackedNumbersStream packedStreamOpen(String prefix) throws SVNException { myFile.seek(myFile.getL2POffset()); final int length = prefix.length(); final byte[] headerBytes = new byte[length]; try { final int bytesRead = myFile.read(headerBytes, 0, length); if (bytesRead != length) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.FS_INDEX_CORRUPTION); SVNErrorManager.error(errorMessage, SVNLogType.FSFS); } } catch (IOException e) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e); SVNErrorManager.error(errorMessage, SVNLogType.FSFS); } if (!Arrays.equals(headerBytes, prefix.getBytes())) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.FS_INDEX_CORRUPTION, "Index stream header prefix mismatch.\n" + " expected: {0}" + " found: {1}", new Object[]{prefix, new String(headerBytes)}); SVNErrorManager.error(errorMessage, SVNLogType.FSFS); } return new FSPackedNumbersStream(myFile); }