shithub: mc

Download patch

ref: 76c13fb5d6c1ba31a4d930e3db5f5466f263f6fb
parent: 791c39b9e378c3ce189dce1119c272b66393e6a0
author: Ori Bernstein <[email protected]>
date: Tue Aug 26 11:05:41 EDT 2014

Add dial() to bio.

--- a/bio.myr
+++ b/bio.myr
@@ -24,6 +24,7 @@
 	/* creation */
 	const mkfile	: (fd : std.fd, mode : mode	-> file#)
 	const open	: (path : byte[:], mode : mode	-> std.option(file#))
+	const dial	: (srv	: byte[:], mode : mode	-> std.option(file#))
 	const create	: (path : byte[:], mode : mode, perm : int	-> std.option(file#))
 	const close	: (f : file# -> bool)
 
@@ -93,6 +94,14 @@
 */
 const create = {path, mode, perm
 	-> sysopen(path, mode, sysmode(mode) | std.Ocreat, perm)
+}
+
+/* dial the server, and open a file using the returned fd */
+const dial = {srv, mode
+	match std.dial(srv)
+	| `std.Ok sock:	-> `std.Some mkfile(sock, mode)
+	| `std.Fail _:	-> `std.None
+	;;
 }
 
 /* map from the bio modes to the unix open modes */