diff --git a/core/src/vfs.sld b/core/src/vfs.sld index bd1d4f4..e09e8f5 100644 --- a/core/src/vfs.sld +++ b/core/src/vfs.sld @@ -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))))) +