diff src/sim.tp @ 20:50a456168c25

Split readFd out of readFile for use in lifter. Add code to read map from stdin to lifter using code in sim
author Mike Pavone <pavone@retrodev.com>
date Sat, 14 Jul 2012 12:33:01 -0700
parents 26cfb964fe81
children be6d1cf7b7d7
line wrap: on
line diff
--- a/src/sim.tp	Sat Jul 14 12:09:06 2012 -0700
+++ b/src/sim.tp	Sat Jul 14 12:33:01 2012 -0700
@@ -170,8 +170,7 @@
 		}
 	}
 	
-	readFile <- :path {
-		fd <- os open: path (os O_RDONLY)
+	readFd <- :fd {
 		if: fd < 0 { "" } else: {
 			cur <- ""
 			part <- ""
@@ -181,11 +180,17 @@
 			} do: {
 				cur <- cur . part
 			}
-			os close: fd
 			cur
 		}
 	}
 	
+	readFile <- :path {
+		fd <- os open: path (os O_RDONLY)
+		out <- readFd: fd
+		os close: fd
+		out
+	}
+	
 	getMove <- {
 		os read: 0 1
 	}