about summary refs log tree commit diff stats
path: root/088file.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-08-26 11:27:13 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-08-26 11:27:13 -0700
commit0230a6cc0bf7fc78fe34242300e7a93498d97dd9 (patch)
tree1b5f16026522c3a57be8eaec7a179a17e15ddddd /088file.mu
parent3c261c4426144c9b6873779f6a3e49c41f8d1f45 (diff)
downloadmu-0230a6cc0bf7fc78fe34242300e7a93498d97dd9.tar.gz
3256
Bugfix in filesystem creation. I'm sure there are other fake-filesystem
bugs.
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