planck.io

Planck I/O functionality.

Protocols

Coercions
IOFactory

Types

File

Vars

as-file
as-relative-path
as-url
copy
delete-file
directory?
file
file?
file-attributes
input-stream
list-files
make-input-stream
make-output-stream
make-parents
make-reader
make-writer
output-stream
reader
writer

Protocols

Coercions

Protocol

Coerce between various 'resource-namish' things.

as-file
([x])
Coerce argument to a File.

as-url
([x])
Coerce argument to a goog.Uri.

IOFactory

Protocol

Factory functions that create ready-to-use versions of the various stream types, on top of anything that can be unequivocally converted to the requested kind of stream.

Common options include

:append true to open stream in append mode
:encoding string name of encoding to use, e.g. "UTF-8".

Callers should generally prefer the higher level API provided by reader, writer, input-stream, and output-stream.

make-reader
([x opts])
Creates an IReader. See also IOFactory docs.

make-writer
([x opts])
Creates an IWriter. See also IOFactory docs.

make-input-stream
([x opts])
Creates an IInputStream. See also IOFactory docs.

make-output-stream
([x opts])
Creates an IOutputStream. See also IOFactory docs.

Types

File

Type

Fields: [path]

Represents a file.

Vars

as-file

([x])

Coerce argument to a File.

as-relative-path

([x])

Take an as-file-able thing and return a string if it is a relative path, else throws an exception.

as-url

([x])

Coerce argument to a goog.Uri.

copy

([input output & opts])

Copies input to output. Returns nil or throws an exception.

Input may be an IInputStream or IReader created using planck.io, File, or string.

Output may be an IOutputStram or IWriter created using planck.io, or File.

The opts arg is included for compatibility with clojure.java.io/copy but ignored. If translating between char and byte representations, UTF-8 encoding is assumed.

Does not close any streams except those it opens itself (on a File).

Spec
args: (cat :input any? :output any? :opts (* any?))
ret: nil?

delete-file

([f])

Delete file f.

Spec
args: (cat :f (or :string string? :file file?))

directory?

([dir])

Checks if dir is a directory.

Spec
args: (cat :dir (or :string string? :file file?))
ret: boolean?

file

([arg] [parent child] [parent child & more])

Returns a File, passing each arg to as-file. Multiple-arg versions treat the first argument as parent and subsequent args as children relative to the parent.

Spec
args: (cat :path-or-parent any? :more (* any?))
ret: file?

file?

([x])

Returns true if x is a File.

Spec
args: (s/cat :x any?)
ret: boolean?

file-attributes

([path])

Returns a map containing the attributes of the item at a given path.

Spec args: (cat :path (nillable? (or :string string? :file file?)))
ret: map?

input-stream

([x & opts])

Attempts to coerce its argument into an open IInputStream.

list-files

([dir])

Returns a seq of the Files in dir or nil if dir is not a directory.

Spec args: (cat :dir (or :string string? :file file?))
ret: (coll-of file?)

make-input-stream

([x opts])

Creates an IInputStream. See also IOFactory docs.

make-output-stream

([x opts])
Creates an IOutputStream. See also IOFactory docs.

make-parents

([f & more])

Given the same arg(s) as for file, creates all parent directories of the file they represent.

Spec
args: (cat :path-or-parent any? :more (* any?))
ret: boolean?

make-reader

([x opts])

Creates an IReader. See also IOFactory docs.

make-writer

([x opts])

Creates an IWriter. See also IOFactory docs.

output-stream

([x & opts])

Attempts to coerce its argument into an open IOutputStream.

reader

([x & opts])

Attempts to coerce its argument into an open IPushbackReader.

writer

([x & opts])

Attempts to coerce its argument into an open IWriter.