URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [os/] [dir_unix.go] - Rev 747
Compare with Previous | Blame | View Log
// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// +build darwin freebsd linux netbsd openbsdpackage osimport ("io""syscall")const (blockSize = 4096)func (f *File) readdirnames(n int) (names []string, err error) {// If this file has no dirinfo, create one.if f.dirinfo == nil {f.dirinfo = new(dirInfo)// The buffer must be at least a block long.f.dirinfo.buf = make([]byte, blockSize)}d := f.dirinfosize := nif size <= 0 {size = 100n = -1}names = make([]string, 0, size) // Empty with room to grow.for n != 0 {// Refill the buffer if necessaryif d.bufp >= d.nbuf {d.bufp = 0var errno errord.nbuf, errno = syscall.ReadDirent(f.fd, d.buf)if errno != nil {return names, NewSyscallError("readdirent", errno)}if d.nbuf <= 0 {break // EOF}}// Drain the buffervar nb, nc intnb, nc, names = syscall.ParseDirent(d.buf[d.bufp:d.nbuf], n, names)d.bufp += nbn -= nc}if n >= 0 && len(names) == 0 {return names, io.EOF}return names, nil}
