private SVNProperties parseProperties(byte[] data, int offset, int length) throws SVNException { final FSFile fsFile = new FSFile(data, offset, length); try { return fsFile.readProperties(false, true); } finally { fsFile.close(); } }
public int read() throws IOException { if (myChannel == null || myPosition < myBufferPosition || myPosition >= myBufferPosition + myBuffer.limit()) { if (fill() <= 0) { return -1; } } else { myBuffer.position((int) (myPosition - myBufferPosition)); } int r = (myBuffer.get() & 0xFF); if (myDigest != null) { myDigest.update((byte) r); } myPosition++; return r; }
private int fill() throws IOException { if ((myChannel == null && myInputStream == null) || myPosition < myBufferPosition || (myPosition >= myBufferPosition + myBuffer.limit())) { myBufferPosition = myPosition; getChannel().position(myBufferPosition); myBuffer.clear(); int read = getChannel().read(myBuffer); myBuffer.position(0); myBuffer.limit(read >= 0 ? read : 0); return read; } return 0; }
private long readRevisionFromReportFile() throws IOException { if (read() == '+') { return readNumberFromReportFile(); } return SVNRepository.INVALID_REVISION; }
private PathInfo getNextPathInfo() throws IOException, SVNException { if (myReportIS == null) { myReportIS = new FSFile(myReportFile); } myCurrentPathInfo = myReportIS.readPathInfoFromReportFile(); return myCurrentPathInfo; }
String repHeader = revisionFile.readLine(160); revisionFile.resetDigest(); rawEntries = revisionFile.readProperties(false, true); checksum = revisionFile.digest(); } else if ("DELTA".equals(repHeader)) { StringBuilder outputChecksum = new StringBuilder(); } finally { if(revisionFile != null){ revisionFile.close();
public void openRoot() throws SVNException { // repo format /root/format FSFile formatFile = new FSFile(getRepositoryFormatFile()); int format = -1; try { format = formatFile.readInt(); } catch (NumberFormatException nfe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_VERSION_FILE_FORMAT, "First line of ''{0}'' contains non-digit", formatFile.getFile()); SVNErrorManager.error(err, SVNLogType.FSFS); } finally { formatFile.close(); } if (format != REPOSITORY_FORMAT && format != REPOSITORY_FORMAT_LEGACY) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.REPOS_UNSUPPORTED_VERSION, "Expected repository format ''{0}'' or " + "''{1}''; found format ''{2}''", new Object[] {new Integer(REPOSITORY_FORMAT_LEGACY), new Integer(REPOSITORY_FORMAT), new Integer(format)}); SVNErrorManager.error(err, SVNLogType.FSFS); } myReposFormat = format; }
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 void findMaxIDs(long rev, FSFile revFile, long offset, String[] maxNodeID, String[] maxCopyID) throws SVNException { revFile.seek(offset); Map headers = null; try { headers = revFile.readHeader(); } finally{ revFile.close(); revFile.seek(revNode.getTextRepresentation().getOffset()); FSInputStream.FSRepresentationState repState = FSInputStream.readRepresentationLine(revFile); if (repState.myIsDelta) { SVNProperties rawEntries = revFile.readProperties(false, false); for (Iterator entriesIter = rawEntries.nameSet().iterator(); entriesIter.hasNext();) { String name = (String) entriesIter.next();
while(true) { try { line = readLine(160); // K length or END, there may be EOF. } catch (SVNException e) { if (allowEOF && e.getErrorMessage().getErrorCode() == SVNErrorCode.STREAM_UNEXPECTED_EOF) { SVNErrorManager.error(err, SVNLogType.DEFAULT); allocateReadBuffer(length + 1); read(myReadLineBuffer); myReadLineBuffer.flip(); myReadLineBuffer.limit(myReadLineBuffer.limit() - 1); continue; line = readLine(160); if (line == null || line.length() < 3 || line.charAt(0) != 'V' || line.charAt(1) != ' ') { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.MALFORMED_FILE); allocateReadBuffer(length + 1); read(myReadLineBuffer); myReadLineBuffer.flip(); myReadLineBuffer.limit(myReadLineBuffer.limit() - 1); properties.put(key, dst); } else { SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.FS_CORRUPT, "File ''{0}'' contains unexpected binary property value", getFile()); SVNErrorManager.error(error, cce, SVNLogType.DEFAULT);
long position = 0; try { position = file.position(); file.read(myReadWindowBuffer); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.SVNDIFF_CORRUPT_WINDOW); file.seek(position); myReadWindowBuffer.limit(instructionsLength + dataLength); try { file.read(myReadWindowBuffer); } catch (IOException e) { SVNDebugLog.getDefaultLog().logSevere(SVNLogType.DEFAULT, e);
public FSRevisionNode getRootRevisionNode() throws SVNException { if (myRootRevisionNode == null) { FSFile file = getOwner().getPackOrRevisionFSFile(getRevision()); try { loadOffsets(file); file.seek(myRootOffset); Map headers = file.readHeader(); myRootRevisionNode = FSRevisionNode.fromMap(headers); } finally { file.close(); } } return myRootRevisionNode; }
private byte[] parseRawDeltaProperties(FSRepresentation txtRep, StringBuilder outputChecksum) throws SVNException { FSFile revisionFile = null; revisionFile = openAndSeekRepresentation(txtRep); String repHeader = revisionFile.readLine(160); revisionFile.resetDigest(); rawPropertiesBytes = new byte[(int) txtRep.getSize()]; revisionFile.read(rawPropertiesBytes, 0, rawPropertiesBytes.length); checksum = revisionFile.digest(); if (checksum != null && outputChecksum != null) { outputChecksum.append(checksum); } finally { if (revisionFile != null) { revisionFile.close();
public FSRevisionNode getRevisionNode(FSID id) throws SVNException { FSFile revisionFile = null; if (id.isTxn()) { File file = new File(getTransactionDir(id.getTxnID()), PATH_PREFIX_NODE + id.getNodeID() + "." + id.getCopyID()); revisionFile = new FSFile(file); } else { revisionFile = openAndSeekRevision(id.getRevision(), id.getOffset()); } Map headers = null; try { headers = revisionFile.readHeader(); } finally{ revisionFile.close(); } FSRevisionNode node = FSRevisionNode.fromMap(headers); if (node.isFreshTxnRoot()) { node.setFreshRootPredecessorId(node.getPredecessorId()); } return node; }
FSRepresentationState repState = readRepresentationLine(file); repState.myFile = file; repState.myStart = file.position(); repState.myOffset = repState.myStart; repState.myEnd = repState.myStart + rep.getSize(); int r = file.read(buffer); file.close(); SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getLocalizedMessage()); SVNErrorManager.error(err, ioe, SVNLogType.FSFS); } catch (SVNException svne) { if (file != null) { file.close();
public FSRevisionNode getRevisionNode(FSID id) throws SVNException { FSFile revisionFile = null; if (id.isTxn()) { File file = new File(getTransactionDir(id.getTxnID()), PATH_PREFIX_NODE + id.getNodeID() + "." + id.getCopyID()); revisionFile = new FSFile(file); } else { revisionFile = getRevisionFile(id.getRevision()); revisionFile.seek(id.getOffset()); } Map headers = null; try { headers = revisionFile.readHeader(); } finally{ revisionFile.close(); } return FSRevisionNode.fromMap(headers); }
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); }
while(true) { try { line = readLine(160); // K length or END, there may be EOF. } catch (SVNException e) { if (allowEOF && e.getErrorMessage().getErrorCode() == SVNErrorCode.STREAM_UNEXPECTED_EOF) { SVNErrorManager.error(err); allocateReadBuffer(length + 1); read(myReadLineBuffer); myReadLineBuffer.flip(); myReadLineBuffer.limit(myReadLineBuffer.limit() - 1); continue; line = readLine(160); if (line == null || line.length() < 3 || line.charAt(0) != 'V' || line.charAt(1) != ' ') { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.MALFORMED_FILE); SVNErrorManager.error(err); allocateReadBuffer(length + 1); read(myReadLineBuffer); myReadLineBuffer.flip(); myReadLineBuffer.limit(myReadLineBuffer.limit() - 1);