}
RuntimeValue href = getOption(_href);
try {
final DataStore store = runtime.getDataStore();
String base = href.getBaseURI().toASCIIString();
store.readEntry(href.getString(), base, "*/*", null, new DataReader() {
public void load(URI id, String media, final InputStream src, long len)
throws IOException {
RuntimeValue target = getOption(_target);
URI uri = store.writeEntry(target.getString(), target.getBaseURI().toASCIIString(), media, new DataWriter() {
public void store(OutputStream dst) throws IOException {
byte[] buffer = new byte[bufsize];
int read = src.read(buffer, 0, bufsize);
while (read >= 0) {
dst.write(buffer, 0, read);
read = src.read(buffer, 0, bufsize);
}
}
});
TreeWriter tree = new TreeWriter(runtime);
tree.startDocument(step.getNode().getBaseURI());
tree.addStartElement(XProcConstants.c_result);
tree.startContent();
tree.addText(uri.toASCIIString());
tree.addEndElement();
tree.endDocument();
result.write(tree.getResult());
}
});
store.deleteEntry(href.getString(), base);
} catch (FileNotFoundException fnfe) {
URI uri = href.getBaseURI().resolve(href.getString());
throw new XProcException(step.getNode(), "Cannot copy: file does not exist: " + uri.toASCIIString());
} catch (IOException ioe) {