Basic IO utilities for streams, files, GZIP encoding and decoding, MIME detection, and similar things. The goal is to not depend on the clojure.java.io namespace.
Basic IO utilities for streams, files, GZIP encoding and decoding, MIME detection, and similar things. The goal is to not depend on the clojure.java.io namespace.
(file arg)(file parent child)(file parent child & more)A proxy to the standard io/file function.
A proxy to the standard io/file function.
(file->extension file)Given a file instance, return if extension detected as everything after the last dot.
Given a file instance, return if extension detected as everything after the last dot.
(file->mime-type file)Given a file instance, guess its MIME type by an extension. Only basic types are supported. Default is application/octet-stream.
Given a file instance, guess its MIME type by an extension. Only basic types are supported. Default is application/octet-stream.
(file-exists? file)Whether the file exists or not.
Whether the file exists or not.
(file-size file)Return the file size in bytes as Long.
Return the file size in bytes as Long.
(file? src)(get-temp-file)(get-temp-file prefix suffix)Return an temporal file, an instance of java.io.File class.
Return an temporal file, an instance of java.io.File class.
(gzip-input-stream src)Coerce the source into the GZIPInputStream instance.
Coerce the source into the GZIPInputStream instance.
(gzip-output-stream src)Coerce the source into the GZIPOutputStream instance.
Coerce the source into the GZIPOutputStream instance.
(gzip-reader src)(input-stream src)(input-stream src & opts)A proxy to the standard io/input-stream function.
A proxy to the standard io/input-stream function.
(input-stream? src)(is-directory? file)Whether the file is a directory or not
Whether the file is a directory or not
(output-stream src)(output-stream src & opts)A proxy to the standard io/output-stream function.
A proxy to the standard io/output-stream function.
(output-stream? src)(pushback-reader src)(read-bytes src)Read all bytes from a source into a byte array.
Read all bytes from a source into a byte array.
(read-edn src)(read-edn src opt)Like clojure.edn/read but wraps the input into
the pushback reader under the hood. The src is
anything which can be converted into an input-stream.
Like `clojure.edn/read` but wraps the input into the pushback reader under the hood. The `src` is anything which can be converted into an input-stream.
(reader src)(reader src & opts)A proxy to the standard io/reader function.
A proxy to the standard io/reader function.
(reader? src)(resource! path)Get a resource throwing an exception when it's missing.
Get a resource throwing an exception when it's missing.
(with-pipe [out in size] & body)A macro to manage piped writing/reading across two threads. The idea is to write bytes into an output but not exhaust disk and memory, while another thread is consuming the connected input stream.
out is bound to a new instance of PipedOutputStreamin is bound to a new instance of PipedInputStreamsize is an optional size for the in.The in is connected to the out meaning everything written to the out is available from in again. The out gets closed when exiting the macro. The in does not because it is used in another thread. You spawn a future that reads from the in, write anything you want to the out, and return the future. Example:
(with-pipe [o i 0xFF] (let [fut (future (.readAllBytes i))] (doseq [x (range 0 3)] (.write o x)) fut))
Both out and in can be wrapped with Gzip in/output streams, writers/readers, etc.
A macro to manage piped writing/reading across two threads.
The idea is to write bytes into an output but not exhaust
disk and memory, while another thread is consuming the
connected input stream.
- `out` is bound to a new instance of PipedOutputStream
- `in` is bound to a new instance of PipedInputStream
- `size` is an optional size for the in.
The in is connected to the out meaning everything written
to the out is available from in again. The out gets closed
when exiting the macro. The in does not because it is used
in another thread. You spawn a future that reads from
the in, write anything you want to the out, and return
the future. Example:
(with-pipe [o i 0xFF]
(let [fut (future
(.readAllBytes i))]
(doseq [x (range 0 3)]
(.write o x))
fut))
Both out and in can be wrapped with Gzip in/output streams,
writers/readers, etc.
(with-tmp-file [bind prefix suffix] & body)Execute the body while the bind symbol is bound
to a temporal file. Afterwards, the file is deleted.
Execute the body while the `bind` symbol is bound to a temporal file. Afterwards, the file is deleted.
(write-file src file)Write src into a given File instance.
Write src into a given File instance.
(write-temp-file src)(write-temp-file src prefix suffix)Write src into temp file and return it.
Write src into temp file and return it.
(write-temp-file-gzip src)Write src into a gzipped temp file and return it.
Write src into a gzipped temp file and return it.
(writer src)(writer src & opts)A proxy to the standard io/writer function.
A proxy to the standard io/writer function.
(writer? src)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |