(zilch vfs): add vfs-append-file
This commit is contained in:
parent
80883d3206
commit
8eb1934d03
1 changed files with 10 additions and 2 deletions
|
|
@ -13,7 +13,7 @@
|
|||
vfs-dir-filter vfs-dir-filter-all
|
||||
vfs-subdir
|
||||
vfs-from-directory vfs-from-store
|
||||
vfs-to-store)
|
||||
vfs-to-store vfs-append-file)
|
||||
|
||||
(begin
|
||||
(define (read-full-file port)
|
||||
|
|
@ -132,4 +132,12 @@
|
|||
store-path
|
||||
(let ((osdir (store-path-realised store-path)))
|
||||
; TODO(puck): use builtin:fetchurl here instead of reimporting (requires divining a hash first)
|
||||
(vfs-from-directory osdir))))))
|
||||
(vfs-from-directory osdir))))
|
||||
|
||||
;; Returns a new VFS, with one file added.
|
||||
(define (vfs-append-file vfs path contents)
|
||||
(define split (string-contains-right path "/"))
|
||||
(define dirname (if split (string-copy path 0 split) ""))
|
||||
(define filename (if split (string-copy path (+ 1 split)) path))
|
||||
(make-vfs (mapping-set (vfs-contents vfs) (cons dirname filename) contents)))))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue