Planck I/O functionality.
Protocols
Types
Vars
as-file
as-relative-path
as-url
copy
delete-file
directory?
exists?
file
file?
file-attributes
file-name
hidden-file?
input-stream
list-files
make-input-stream
make-output-stream
make-parents
make-reader
make-writer
output-stream
path-elements
reader
regular-file?
resource
symbolic-link?
tty?
writer
Coerce between various 'resource-namish' things.
as-file
([x])
Coerce argument to a File
.
as-url
([x])
Coerce argument to a goog.Uri
.
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.
Type
Fields: [path]
Represents a file.
([x])
Coerce argument to a File
.
([x])
Take an as-file
-able thing and return a string if it is a relative path, else throws an exception.
([x])
Coerce argument to a goog.Uri
.
([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?
([f])
Delete file f
.
Spec
args: (cat :f (or :string string? :file file?))
([dir])
Checks if dir
is a directory.
Spec
args: (cat :dir (or :string string? :file file?))
ret: boolean?
([f])
Checks if f
exists on disk.
Spec
args: (cat :f (or :string string? :file file?))
ret: boolean?
([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?
([x])
Returns true
if x
is a File
.
Spec
args: (s/cat :x any?)
ret: boolean?
([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?
([x])
Returns the name (the final path element) of x
.
Spec
args: (cat :x (or :string string? :file file?))
ret: string?
([x])
Checks if x
is hidden (name begins with a '.' character).
Spec
args: (cat :x (or :string string? :file file?))
ret: boolean?
([x & opts])
Attempts to coerce its argument into an open IInputStream
.
([dir])
Returns a seq of the File
s in dir
or nil
if dir
is not a directory.
Spec args: (cat :dir (or :string string? :file file?))
ret: (coll-of file?)
([x opts])
Creates an IInputStream
. See also IOFactory
docs.
([x opts])
IOutputStream
. See also IOFactory
docs.([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?
([x opts])
Creates an IReader
. See also IOFactory
docs.
([x opts])
Creates an IWriter
. See also IOFactory
docs.
([x & opts])
Attempts to coerce its argument into an open IOutputStream
.
([x])
Returns the path elements of x
as a sequence.
Spec
args: (cat :x (or :string string? :file file?))
ret: (s/coll-of string?)
([x & opts])
Attempts to coerce its argument into an open IPushbackReader
.
([f])
Checks if f
is a regular file.
Spec
args: (cat :f (or :string string? :file file?))
ret: boolean?
([n])
Returns the URI for the named resource, n
.
cljs.test
is "cljs/test.cljs"
.Spec
args: (cat :n (nilable string?))
ret: (nilable (instance? Uri %))
([f])
Checks if f
is a symbolic link.
Spec
args: (cat :f (or :string string? :file file?))
ret: boolean?
([x])
Checks if x
is a file descriptor associated with a terminal. x
may be a file descriptor number or one of planck.core/*in*
, cljs.core/*out*
or planck.core/*err*
.
Spec
x: (or :fd-num (and integer? (complement neg?)) :reader #(implements? planck.core/IReader %) :writer #(implements? planck.core/IWriter %))
ret: boolean?
([x & opts])
Attempts to coerce its argument into an open IWriter
.