diff options
author | Robert Griesemer <gri@golang.org> | 2009-03-02 20:27:09 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-03-02 20:27:09 -0800 |
commit | 283668dc71ce1ed7e40112b07953b3abdcf69d23 (patch) | |
tree | 9a4be091b0dcbe319409d1b32981628a308f0020 /usr/gri/pretty/platform.go | |
parent | 97a5240489037e952b8a1bd220e50e988ca50b54 (diff) | |
download | golang-283668dc71ce1ed7e40112b07953b3abdcf69d23.tar.gz |
scanner cleanup - getting it ready to as a library
- removed unneeded code that accumulated over time
- change src from string to []byte (perhaps should be io.Read
but that has some other disadvantages)
- simplified interface
R=r
OCL=25615
CL=25615
Diffstat (limited to 'usr/gri/pretty/platform.go')
-rw-r--r-- | usr/gri/pretty/platform.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/usr/gri/pretty/platform.go b/usr/gri/pretty/platform.go index ef82d9565..3037ac300 100644 --- a/usr/gri/pretty/platform.go +++ b/usr/gri/pretty/platform.go @@ -37,10 +37,10 @@ const ( Obj_file_ext = ".7"; ) -func readfile(filename string) (string, *OS.Error) { +func readfile(filename string) ([]byte, *OS.Error) { fd, err := OS.Open(filename, OS.O_RDONLY, 0); if err != nil { - return "", err; + return []byte(), err; } var buf [1<<20]byte; n, err1 := IO.Readn(fd, buf); @@ -48,7 +48,7 @@ func readfile(filename string) (string, *OS.Error) { if err1 == IO.ErrEOF { err1 = nil; } - return string(buf[0:n]), err1; + return buf[0:n], err1; } func writefile(name, data string) *OS.Error { @@ -61,17 +61,17 @@ func writefile(name, data string) *OS.Error { return err1; } -func ReadObjectFile(filename string) (string, bool) { +func ReadObjectFile(filename string) ([]byte, bool) { data, err := readfile(filename + Obj_file_ext); magic := MAGIC_obj_file; // TODO remove once len(constant) works - if err == nil && len(data) >= len(magic) && data[0 : len(magic)] == magic { + if err == nil && len(data) >= len(magic) && string(data[0 : len(magic)]) == magic { return data, true; } - return "", false; + return []byte(), false; } -func ReadSourceFile(name string) (string, bool) { +func ReadSourceFile(name string) ([]byte, bool) { name = Utils.TrimExt(name, Src_file_ext) + Src_file_ext; data, err := readfile(name); return data, err == nil; |