portable stat for os
add name to os.FD
clean up some interfaces
R=rsc
DELTA=318 (231 added, 44 deleted, 43 changed)
OCL=24624
CL=24627
diff --git a/src/lib/io/io.go b/src/lib/io/io.go
index 54f18fb..1004ac9 100644
--- a/src/lib/io/io.go
+++ b/src/lib/io/io.go
@@ -34,14 +34,19 @@
Close() *os.Error;
}
-func WriteString(w Write, s string) (n int, err *os.Error) {
- b := make([]byte, len(s)+1);
- if !syscall.StringToBytes(b, s) {
- return -1, os.EINVAL
+// Convert a string to an array of bytes for easy marshaling.
+// Could fill with syscall.StringToBytes but it adds an unnecessary \000
+// so the length would be wrong.
+func StringBytes(s string) []byte {
+ b := make([]byte, len(s));
+ for i := 0; i < len(s); i++ {
+ b[i] = s[i];
}
- // BUG return w.Write(b[0:len(s)])
- r, e := w.Write(b[0:len(s)]);
- return r, e
+ return b;
+}
+
+func WriteString(w Write, s string) (n int, err *os.Error) {
+ return w.Write(StringBytes(s))
}
// Read until buffer is full, EOF, or error
@@ -147,14 +152,3 @@
}
return written, err
}
-
-// Convert a string to an array of bytes for easy marshaling.
-// Could fill with syscall.StringToBytes but it adds an unnecessary \000
-// so the length would be wrong.
-func StringBytes(s string) []byte {
- b := make([]byte, len(s));
- for i := 0; i < len(s); i++ {
- b[i] = s[i];
- }
- return b;
-}