aboutsummaryrefslogtreecommitdiff
path: root/src/lib/io
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-04-17 00:08:24 -0700
committerRob Pike <r@golang.org>2009-04-17 00:08:24 -0700
commitaaf63f8d06cda8308eb7c47ebc1f2cf2c1c91d02 (patch)
treec20f34ec6f9dea967a511f65b239c5e8637fec8f /src/lib/io
parent3ea8d854a3a0b7f812d8590d4d1c3c2671288b60 (diff)
downloadgo-aaf63f8d06cda8308eb7c47ebc1f2cf2c1c91d02.tar.xz
Step 1 of the Big Error Shift: make os.Error an interface and replace *os.Errors with os.Errors.
lib/template updated to use new setup; its clients also updated. Step 2 will make os's error support internally much cleaner. R=rsc OCL=27586 CL=27586
Diffstat (limited to 'src/lib/io')
-rw-r--r--src/lib/io/bytebuffer.go4
-rw-r--r--src/lib/io/io.go16
-rw-r--r--src/lib/io/pipe.go18
3 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/io/bytebuffer.go b/src/lib/io/bytebuffer.go
index 440f265c53..9c78e8566f 100644
--- a/src/lib/io/bytebuffer.go
+++ b/src/lib/io/bytebuffer.go
@@ -40,7 +40,7 @@ func (b *ByteBuffer) Reset() {
// Write appends the contents of p to the buffer. The return
// value is the length of p; err is always nil.
-func (b *ByteBuffer) Write(p []byte) (n int, err *os.Error) {
+func (b *ByteBuffer) Write(p []byte) (n int, err os.Error) {
plen := len(p);
if len(b.buf) == 0 {
b.cap = plen + 1024;
@@ -60,7 +60,7 @@ func (b *ByteBuffer) Write(p []byte) (n int, err *os.Error) {
// Read reads the next len(p) bytes from the buffer or until the buffer
// is drained. The return value is the number of bytes read; err is always nil.
-func (b *ByteBuffer) Read(p []byte) (n int, err *os.Error) {
+func (b *ByteBuffer) Read(p []byte) (n int, err os.Error) {
plen := len(p);
if len(b.buf) == 0 {
return 0, nil
diff --git a/src/lib/io/io.go b/src/lib/io/io.go
index 73406668fb..2c116687b9 100644
--- a/src/lib/io/io.go
+++ b/src/lib/io/io.go
@@ -18,17 +18,17 @@ var ErrEOF = os.NewError("EOF")
// Read is the interface that wraps the basic Read method.
type Read interface {
- Read(p []byte) (n int, err *os.Error);
+ Read(p []byte) (n int, err os.Error);
}
// Write is the interface that wraps the basic Write method.
type Write interface {
- Write(p []byte) (n int, err *os.Error);
+ Write(p []byte) (n int, err os.Error);
}
// Close is the interface that wraps the basic Close method.
type Close interface {
- Close() *os.Error;
+ Close() os.Error;
}
// ReadWrite is the interface that groups the basic Read and Write methods.
@@ -66,12 +66,12 @@ func StringBytes(s string) []byte {
}
// WriteString writes the contents of the string s to w, which accepts an array of bytes.
-func WriteString(w Write, s string) (n int, err *os.Error) {
+func WriteString(w Write, s string) (n int, err os.Error) {
return w.Write(StringBytes(s))
}
// Readn reads r until the buffer buf is full, or until EOF or error.
-func Readn(r Read, buf []byte) (n int, err *os.Error) {
+func Readn(r Read, buf []byte) (n int, err os.Error) {
n = 0;
for n < len(buf) {
nn, e := r.Read(buf[n:len(buf)]);
@@ -94,7 +94,7 @@ type fullRead struct {
r Read;
}
-func (fr *fullRead) Read(p []byte) (n int, err *os.Error) {
+func (fr *fullRead) Read(p []byte) (n int, err os.Error) {
n, err = Readn(fr.r, p);
return n, err
}
@@ -111,7 +111,7 @@ func MakeFullReader(r Read) Read {
// Copy n copies n bytes (or until EOF is reached) from src to dst.
// It returns the number of bytes copied and the error, if any.
-func Copyn(src Read, dst Write, n int64) (written int64, err *os.Error) {
+func Copyn(src Read, dst Write, n int64) (written int64, err os.Error) {
buf := make([]byte, 32*1024);
for written < n {
l := len(buf);
@@ -147,7 +147,7 @@ func Copyn(src Read, dst Write, n int64) (written int64, err *os.Error) {
// Copy copies from src to dst until EOF is reached.
// It returns the number of bytes copied and the error, if any.
-func Copy(src Read, dst Write) (written int64, err *os.Error) {
+func Copy(src Read, dst Write) (written int64, err os.Error) {
buf := make([]byte, 32*1024);
for {
nr, er := src.Read(buf);
diff --git a/src/lib/io/pipe.go b/src/lib/io/pipe.go
index 427717b09a..446ec69bb4 100644
--- a/src/lib/io/pipe.go
+++ b/src/lib/io/pipe.go
@@ -15,7 +15,7 @@ import (
type pipeReturn struct {
n int;
- err *os.Error;
+ err os.Error;
}
// Shared pipe structure.
@@ -28,7 +28,7 @@ type pipe struct {
cw chan pipeReturn; // ... and reads the n, err back from here.
}
-func (p *pipe) Read(data []byte) (n int, err *os.Error) {
+func (p *pipe) Read(data []byte) (n int, err os.Error) {
if p == nil || p.rclosed {
return 0, os.EINVAL;
}
@@ -65,7 +65,7 @@ func (p *pipe) Read(data []byte) (n int, err *os.Error) {
return n, nil;
}
-func (p *pipe) Write(data []byte) (n int, err *os.Error) {
+func (p *pipe) Write(data []byte) (n int, err os.Error) {
if p == nil || p.wclosed {
return 0, os.EINVAL;
}
@@ -81,7 +81,7 @@ func (p *pipe) Write(data []byte) (n int, err *os.Error) {
return res.n, res.err;
}
-func (p *pipe) CloseReader() *os.Error {
+func (p *pipe) CloseReader() os.Error {
if p == nil || p.rclosed {
return os.EINVAL;
}
@@ -97,7 +97,7 @@ func (p *pipe) CloseReader() *os.Error {
return nil;
}
-func (p *pipe) CloseWriter() *os.Error {
+func (p *pipe) CloseWriter() os.Error {
if p == nil || p.wclosed {
return os.EINVAL;
}
@@ -127,14 +127,14 @@ type pipeRead struct {
p *pipe;
}
-func (r *pipeRead) Read(data []byte) (n int, err *os.Error) {
+func (r *pipeRead) Read(data []byte) (n int, err os.Error) {
r.lock.Lock();
defer r.lock.Unlock();
return r.p.Read(data);
}
-func (r *pipeRead) Close() *os.Error {
+func (r *pipeRead) Close() os.Error {
r.lock.Lock();
defer r.lock.Unlock();
@@ -151,14 +151,14 @@ type pipeWrite struct {
p *pipe;
}
-func (w *pipeWrite) Write(data []byte) (n int, err *os.Error) {
+func (w *pipeWrite) Write(data []byte) (n int, err os.Error) {
w.lock.Lock();
defer w.lock.Unlock();
return w.p.Write(data);
}
-func (w *pipeWrite) Close() *os.Error {
+func (w *pipeWrite) Close() os.Error {
w.lock.Lock();
defer w.lock.Unlock();