java.io: full File API + byte/char streams over Chez ports
Expand java.io so libraries that touch the filesystem work unchanged.
File: the full method surface — length, lastModified, can{Read,Write,Execute},
isHidden, list, mkdir(s), delete, createNewFile, renameTo, getParentFile,
get{Absolute,Canonical}File, compareTo/equals/hashCode — plus the statics
separator / pathSeparator / createTempFile / listRoots. A File now keeps the
path as given (new File("rel").getPath() is "rel", .isAbsolute false); a
relative path resolves against JOLT_PWD only when the filesystem is touched,
matching the JVM. slurp/spit and the dir helpers go through the same
resolution, fixing a spit-vs-slurp inconsistency.
Streams (host/chez/io-streams.ss) — each a jhost wrapping a Chez port, so
buffering, EOF and binary<->char transcoding come from Chez:
- FileInputStream / FileOutputStream / ByteArrayInputStream /
ByteArrayOutputStream / BufferedInputStream / BufferedOutputStream
- FileReader / FileWriter / InputStreamReader / OutputStreamWriter /
BufferedReader / BufferedWriter
Buffered* return the wrapped stream (Chez ports are already buffered).
clojure.java.io: input-stream/output-stream now yield real byte streams (were
aliased to the char reader/writer); added copy (byte-exact for byte sources),
make-parents, delete-file. with-open also closes file-writer/port-writer/
print-writer (a pre-existing gap).
All runtime shims, no re-mint. 15 JVM-certified corpus rows; make test +
shakesmoke green.
This commit is contained in:
parent
7bc4288e98
commit
1853d827bd
5 changed files with 480 additions and 24 deletions
|
|
@ -70,12 +70,29 @@ aren't implemented; a few are accepted but no-ops (noted inline).
|
|||
|
||||
### I/O
|
||||
|
||||
- **`java.io.File`** — `(File. path)` / `(File. parent child)`; `getPath`
|
||||
`getName` `getAbsolutePath` `getCanonicalPath` `toURI` `toURL` `exists`
|
||||
`isDirectory` `isFile` `listFiles` `getParent`.
|
||||
- **`java.io.StringReader` / `StringWriter` / `PushbackReader`** — the
|
||||
`read`/`readLine`/`mark`/`reset`/`unread`/`write`/`append`/`toString` surface
|
||||
the reader and `with-out-str` rely on.
|
||||
- **`java.io.File`** — `(File. path)` / `(File. parent child)`. A File keeps the
|
||||
path as given (`(.getPath (File. "rel"))` is `"rel"`, `.isAbsolute` false); a
|
||||
relative path resolves against `JOLT_PWD` only when the filesystem is touched.
|
||||
Methods: `getPath` `getName` `getParent` `getParentFile` `getAbsolutePath`
|
||||
`getAbsoluteFile` `getCanonicalPath` `getCanonicalFile` `toURI` `toURL`
|
||||
`exists` `isDirectory` `isFile` `isAbsolute` `isHidden` `length` `lastModified`
|
||||
`canRead` `canWrite` `canExecute` `list` `listFiles` `mkdir` `mkdirs` `delete`
|
||||
`createNewFile` `renameTo` `compareTo` `equals` `hashCode`. Statics:
|
||||
`File/separator` `File/separatorChar` `File/pathSeparator` `File/createTempFile`
|
||||
`File/listRoots`.
|
||||
- **Byte streams** — `FileInputStream` / `FileOutputStream` (over a path/File,
|
||||
`append` arg), `ByteArrayInputStream` / `ByteArrayOutputStream`
|
||||
(`toByteArray`/`toString`/`size`/`reset`), `BufferedInputStream` /
|
||||
`BufferedOutputStream`. `read`/`read(byte[])`, `write(int)`/`write(byte[])`,
|
||||
`flush`, `close`. Each is a Chez binary port underneath.
|
||||
- **Char streams** — `FileReader` / `InputStreamReader` (read a byte stream as
|
||||
UTF-8), `FileWriter` / `OutputStreamWriter`, `BufferedReader` (`readLine`,
|
||||
`lines`) / `BufferedWriter` (`newLine`), `StringReader` / `StringWriter` /
|
||||
`PushbackReader`.
|
||||
- **`clojure.java.io`** — `file` `as-file` `reader` `writer` `input-stream`
|
||||
`output-stream` `copy` (byte-exact for byte sources) `make-parents`
|
||||
`delete-file` `resource` `as-url`. `slurp`/`spit`/`line-seq`/`with-open` work
|
||||
over all of the above.
|
||||
- **`java.lang.ClassLoader`** — `getSystemClassLoader`, `.getResource`,
|
||||
`.getResourceAsStream` (resolved against the source roots).
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue