Newer
Older
// 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 dragonfly freebsd linux nacl netbsd openbsd solaris
func (f *File) readdirnames(n int) (names []string, err error) {
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.dirinfo
size := n
size = 100
names = make([]string, 0, size) // Empty with room to grow.
// Refill the buffer if necessary
if d.bufp >= d.nbuf {
d.nbuf, errno = fixCount(syscall.ReadDirent(f.fd, d.buf))
return names, NewSyscallError("readdirent", errno)
nb, nc, names = syscall.ParseDirent(d.buf[d.bufp:d.nbuf], n, names)
if n >= 0 && len(names) == 0 {