Artifact 740797091727ff66559c8f652884adf568552696521cef45c56165871a826611:
- Executable file
r37/lisp/csl/jlisp/PDSInputStream.java
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 1305) [annotate] [blame] [check-ins using] [more...]
// // This file is part of the Jlisp implementation of Standard Lisp // Copyright \u00a9 (C) Codemist Ltd, 1998-2000. // import java.io.*; class PDSInputStream extends InputStream { PDS pds; long savedPosition; int left; PDSInputStream(PDS pds, String member) throws IOException { this.pds = pds; if (pds == null || (pds.f == null && pds.data == null)) throw new IOException("PDS member " + member + " not found"); Object on = pds.directory.get(member); if (on == null) throw new IOException("PDS member " + member + " not found"); left = ((PDSEntry)on).len; savedPosition = pds.getFilePointer(); pds.seek((long)((PDSEntry)on).loc); } public int available() { return left; } public void close() throws IOException { pds.seek(savedPosition); } public boolean markSupported() { return false; } public int read() throws IOException { if (left <= 0) return -1; else { left--; return pds.read(); } } public int read(byte [] b) throws IOException { return read(b, 0, b.length); } public int read(byte [] b, int off, int len) throws IOException { if (left <= 0) return -1; if (left < len) len = left; int n = pds.read(b, off, len); left -= n; return n; } } // end of PDSInputStream.java