Host filesystem resources.

1
2
3
(with-scope
  (config (acquire! (file "project.clj")))
;;=> #dunaj.resource.file.FileResourceFactory{:uri #uri \"file:///data/proj/dunaj/./project.clj\", :mode [:read :write :create], :batch-size 8192, :file-system #<LinuxFileSystem sun.nio.fs.LinuxFileSystem@35267b1e>, :working-directory nil})
1
2
3
4
5
6
7
8
9
10
(with-scope (str (take 20 (slurp "project.clj"))))
;;=> "(defproject dunaj \"1"

;; append by default
(with-scope (spit! "out.txt" "lorem ipsum"))
;;=> 11

;; custom mode
(with-scope (spit! "out.txt" "lorem ipsum" :truncate))
;;=> 11

file

Available since version 1.0 (view source)

Usage:
  • (file uri & {:as opts})

Type signature:
  • ((U nil String+ Uri) ⨯ Any) → (I IImmutableReadable IAcquirableFactory)

Returns factory for passable thread local files, with given uri and opts set.

In addition to readable and writable, files are flushable, seekable and truncatable.

file-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type (I IImmutableReadable IAcquirableFactory)

A file resource factory. Passable thread local. Current options are:

  • :uri - file uri

  • :mode - host specific, usually a combination of :append, :create, :new, :delete, :dsync, :read, :sparse, :sync, :truncate and :write

  • :batch-size - default batch size, low level

  • :file-system - nil or host specifis filesystem object

  • :working-directory - nil or URI of a working directory

Use config to get configuration parameters from an acquired file resource.

See also: file

truncate!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (truncate! res size)

Type signature:
  • (ITruncatable ⨯ Integer+) → nil

Truncates given resource res to size. Returns nil.