}
return tokens;
}
private void doGetLocalFileContents(File path, OutputStream dst, SVNRevision revision, boolean expandKeywords) throws SVNException {
SVNWCAccess wcAccess = createWCAccess();
InputStream input = null;
boolean hasMods = false;
SVNVersionedProperties properties = null;
try {
SVNAdminArea area = wcAccess.open(path.getParentFile(), false, 0);
SVNEntry entry = wcAccess.getVersionedEntry(path, false);
if (entry.getKind() != SVNNodeKind.FILE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNVERSIONED_RESOURCE, "''{0}'' refers to a directory", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
String name = path.getName();
if (revision != SVNRevision.WORKING) {
// get base version and base props.
input = area.getBaseFileForReading(name, false);
properties = area.getBaseProperties(name);
} else {
// get working version and working props.
input = SVNFileUtil.openFileForReading(area.getFile(path.getName()), SVNLogType.WC);
hasMods = area.hasPropModifications(name) || area.hasTextModifications(name, true);
properties = area.getProperties(name);
}
String charsetProp = properties.getStringPropertyValue(SVNProperty.CHARSET);
String eolStyle = properties.getStringPropertyValue(SVNProperty.EOL_STYLE);
String keywords = properties.getStringPropertyValue(SVNProperty.KEYWORDS);
boolean special = properties.getPropertyValue(SVNProperty.SPECIAL) != null;
byte[] eols = null;
Map keywordsMap = null;
String time = null;
String charset = SVNTranslator.getCharset(charsetProp, path.getPath(), getOptions());
eols = SVNTranslator.getEOL(eolStyle, getOptions());
if (hasMods && !special) {
time = SVNDate.formatDate(new Date(path.lastModified()));
} else {
time = entry.getCommittedDate();
}
if (keywords != null) {
String url = entry.getURL();
String author = hasMods ? "(local)" : entry.getAuthor();
String rev = hasMods ? entry.getCommittedRevision() + "M" : entry.getCommittedRevision() + "";
keywordsMap = SVNTranslator.computeKeywords(keywords, expandKeywords ? url : null, author, time, rev, getOptions());
}
OutputStream translatingStream = charset != null || eols != null || keywordsMap != null ? SVNTranslator.getTranslatingOutputStream(dst, charset, eols, false, keywordsMap, expandKeywords) : dst;
try {
SVNTranslator.copy(input, new SVNCancellableOutputStream(translatingStream, getEventDispatcher()));
if (translatingStream != dst) {
SVNFileUtil.closeFile(translatingStream);
}
dst.flush();
} catch (IOExceptionWrapper ioew) {
throw ioew.getOriginalException();
} catch (IOException e) {
if (e instanceof SVNCancellableOutputStream.IOCancelException) {
SVNErrorManager.cancel(e.getMessage(), SVNLogType.NETWORK);
}
SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getMessage()), SVNLogType.WC);
}
} finally {
SVNFileUtil.closeFile(input);
wcAccess.close();
}
}