about summary refs log tree commit diff stats
path: root/088file.mu
diff options
context:
space:
mode:
Diffstat (limited to '088file.mu')
-rw-r--r--088file.mu12
1 files changed, 12 insertions, 0 deletions
diff --git a/088file.mu b/088file.mu
index 19539b95..012de50a 100644
--- a/088file.mu
+++ b/088file.mu
@@ -117,7 +117,19 @@ def transmit-to-fake-file fs:address:filesystem, filename:address:array:characte
   curr-filename:address:array:character <- copy 0
   data:address:array:file-mapping <- get *fs, data:offset
   # replace file contents if it already exists
+  i:number <- copy 0
   len:number <- length *data
+  {
+    done?:boolean <- greater-or-equal i, len
+    break-if done?
+    tmp:file-mapping <- index *data, i
+    curr-filename <- get tmp, name:offset
+    found?:boolean <- equal filename, curr-filename
+    loop-unless found?
+    put-index *data, i, new-file-mapping
+    reply
+  }
+  # if file didn't already exist, make room for it
   new-len:number <- add len, 1
   new-data:address:array:file-mapping <- new file-mapping:type, new-len
   put *fs, data:offset, new-data