// System.out.println("##[CatExe] : getStdOut():" + getStdOut());
// System.out.println("##[CatExe] : getStdIn():" + getStdIn());
BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
BufferObjectReader oin = new BufferObjectReader(getStdIn());
VFS vfs = shell.getVFS();
FileName pwd = new FileName(shell.getEnvProperty("PWD"));
List paths = new LinkedList();
for (int i = 0; i < params.length; i++) {
String param = params[i];
FileName path = new FileName(param);
if (path.isRelative())
path = pwd.absolutize(path);
path = vfs.resolve(shell.getUserCtx(), path, false);
paths.add(path);
}
// List result = new LinkedList();
// if no paths given, read from stdin
if (!paths.isEmpty()) {
Iterator it = paths.iterator();
while (it.hasNext()) {
FileName path = (FileName) it.next();
FileOpInfo op = new FileOpInfo();
op.filename = path;
// op.offset = 0;
FileReadInfo read = null;
do {
read = vfs.read(shell.getUserCtx(), op);
// if file has no content(is asset, etc.) null is returned by vfs.read()
if (read == null)
break;
op.tag = read.tag;
op.offset += read.buf.length;
oout.writeObject(read.buf);
} while (read.more);
}
} else {
while (!oin.isFinished()) {
Object obj = oin.readObject();
oout.writeObject(obj);
// System.out.println("##[CatExe] writing to out: " + obj);
}
}