package com.perforce.cvs.asset; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Iterator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.perforce.common.asset.ContentStream; import com.perforce.common.asset.ScanContentStream; import com.perforce.svn.parser.Content; public class CvsContentStream extends ContentStream { private Logger logger = LoggerFactory.getLogger(CvsContentStream.class); private ScanContentStream scan = new ScanContentStream(); private Iterator<String> blockIterator; private byte[] remainder; private Iterator<String> markIterator; private byte[] markRemainder; public CvsContentStream(Content content) { this.blockIterator = content.getBlock().iterator(); setFilter(true); } @Override public int read(byte[] b, int off, int len) throws IOException { int count = 0; if (blockIterator.hasNext()) { ByteArrayOutputStream bs = new ByteArrayOutputStream(); do { String line = blockIterator.next(); byte[] bytes = line.getBytes(); if (count + bytes.length > len) { int part = len - count; bs.write(bytes, 0, part); count += part; int left = bytes.length - part; remainder = new byte[left]; System.arraycopy(bytes, part, remainder, 0, left); } else { bs.write(bytes); count += bytes.length; remainder = null; } } while (blockIterator.hasNext() && remainder != null); System.arraycopy(bs.toByteArray(), 0, b, 0, count); bs.close(); } else { return -1; } scan.read(b, count); return count; } @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); } @Override public int read() throws IOException { throw new IOException("Byte read not supported"); } @Override public void mark(int readlimit) { this.markIterator = this.blockIterator; this.markRemainder = this.remainder; } @Override public boolean markSupported() { return true; } @Override public void reset() { this.blockIterator = this.markIterator; this.remainder = this.markRemainder; } @Override public void close() throws IOException { // TODO nothing? } @Override public boolean removeBOM() { logger.warn("NOT IMPLEMENTED YET!"); return true; } @Override public boolean isText() { return scan.isText(); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 13920 | Paul Allen | copy part 2 (no errors) | ||
#5 | 12222 | Paul Allen |
New non-translate mode for high-ascii files. If the P4_TRANSLATE mode is disabled then text files with high-ascii characters are given the new type RAW-TEXT. Raw types are not translated and the content is used as-is. (exception UTF16/32) The default translation configuration is enabled: com.p4convert.p4.translate=true The com.p4convert.p4.translate=false mode is intended for use with non-unicode Perforce servers in a Windows only client environment. |
||
#4 | 10771 | Paul Allen |
Update warning counter, on error/warn state. Stats.inc(StatsType.warningCount); |
||
#3 | 10655 | Paul Allen |
Fixed buffered writer. Fills buffer with one or more lines upto 8K and then save remainder. Includes line/EOF (null) detection. |
||
#2 | 10497 | Paul Allen |
New low-level RCS reader using a byte[] to manage CVS lines. Designed to help with the processing of BINARY data in RCS files. The line reading code still looks for a unix style '\n', but has a MAX LINE (hard coded to 10K). The RcsObjectBlock uses a ByteArrayOutputStream to store lines and parsers uses byte logic. (passes basic cvs/svn unit tests) |
||
#1 | 9807 | Paul Allen | Initial import of p4-convert (from change 894340) |