On this page:
fs-open-input-file
fs-open-output-file
call-with-fs-input-file
call-with-fs-output-file
call-with-fs-input-file*
call-with-fs-output-file*
with-fs-input-from-file
with-fs-output-to-file
Version: 4.1.4.1

3.9 Node Contents

(fs-open-input-file root path)  input-port?
  root : fs-root?
  path : path-string?

Opens an input port from which the contents of the file at path below root can be read.

(fs-open-output-file root 
  path 
  [#:deltify deltify? 
  #:base-checksum base-checksum 
  #:result-checksum result-checksum]) 
  output-stream?
  root : fs-root?
  path : path-string?
  deltify? : any/c = #t
  base-checksum : (or/c bytes? #f) = #f
  result-checksum : (or/c bytes? #f) = #f

Opens an output port to which the new contents of the file at path below root can be written.

If deltify is not #f, writing data to the stream automatically generated a delta to the previous contents of the file. Otherwise, the new revision stores the full new contents of the file.

base-checksum and result-checksum are checksums of the file’s content before and after the change. These arguments may be ignored, even if provided, but if provided, they must be correct.

(call-with-fs-input-file root path proc)  any
  root : fs-root?
  path : path-string?
  proc : (-> input-port? any)

Calls fs-open-input-file with the root and path arguments and passes the resulting port to proc.

When proc returns, the newly opened port is closed.

The result of proc is the result of the call-with-fs-input-file call.

(call-with-fs-output-file root 
  path 
  proc 
  [#:deltify deltify? 
  #:base-checksum base-checksum 
  #:result-checksum result-checksum]) 
  any
  root : fs-root?
  path : path-string?
  proc : (-> output-port? any)
  deltify? : any/c = #t
  base-checksum : (or/c bytes? #f) = #f
  result-checksum : (or/c bytes? #f) = #f

Calls fs-open-output-file with the root, path, deltify?, base-checksum and result-checksum arguments and passes the resulting port to proc.

When proc returns, the newly opened port is closed.

The result of proc is the result of the call-with-fs-output-file call.

(call-with-fs-input-file* root path proc)  any
  root : fs-root?
  path : path-string?
  proc : (-> input-port? any)

Like call-with-fs-input-file, but the newly opened port is closed whenever the dynamic scope of call-with-fs-input-file* is left.

(call-with-fs-output-file* root 
  path 
  proc 
  [#:deltify deltify? 
  #:base-checksum base-checksum 
  #:result-checksum result-checksum]) 
  any
  root : fs-root?
  path : path-string?
  proc : (-> output-port? any)
  deltify? : any/c = #t
  base-checksum : (or/c bytes? #f) = #f
  result-checksum : (or/c bytes? #f) = #f

Like call-with-fs-output-file, but the newly opened port is closed whenever the dynamic scope of call-with-fs-output-file* is left.

(with-fs-input-from-file root path thunk)  any
  root : fs-root?
  path : path-string?
  thunk : (-> any)

Like call-with-fs-input-file*, but the newly opened port is not passed to thunk but rather installed as the current input port using a parameterization.

(with-fs-output-to-file root 
  path 
  thunk 
  [#:deltify deltify? 
  #:base-checksum base-checksum 
  #:result-checksum result-checksum]) 
  any
  root : fs-root?
  path : path-string?
  thunk : (-> any)
  deltify? : any/c = #t
  base-checksum : (or/c bytes? #f) = #f
  result-checksum : (or/c bytes? #f) = #f

Like call-with-fs-output-file*, but the newly opened port is not passed to thunk but rather installed as the current output port using a parameterization.