// 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.//go:build unix || (js && wasm) || wasip1package syscallimport ()// readInt returns the size-bytes unsigned integer in native byte order at offset off.func readInt( []byte, , uintptr) ( uint64, bool) {iflen() < int(+) {return0, false }ifgoarch.BigEndian {returnreadIntBE([:], ), true }returnreadIntLE([:], ), true}func readIntBE( []byte, uintptr) uint64 {switch {case1:returnuint64([0])case2:returnuint64(byteorder.BEUint16())case4:returnuint64(byteorder.BEUint32())case8:returnuint64(byteorder.BEUint64())default:panic("syscall: readInt with unsupported size") }}func readIntLE( []byte, uintptr) uint64 {switch {case1:returnuint64([0])case2:returnuint64(byteorder.LEUint16())case4:returnuint64(byteorder.LEUint32())case8:returnuint64(byteorder.LEUint64())default:panic("syscall: readInt with unsupported size") }}// ParseDirent parses up to max directory entries in buf,// appending the names to names. It returns the number of// bytes consumed from buf, the number of entries added// to names, and the new names slice.func ( []byte, int, []string) ( int, int, []string) { := len() = 0for != 0 && len() > 0 { , := direntReclen()if ! || > uint64(len()) {return , , } := [:] = [:] , := direntIno()if ! {break }// See src/os/dir_unix.go for the reason why this condition is // excluded on wasip1.if == 0 && runtime.GOOS != "wasip1" { // File absent in directory.continue }const = uint64(unsafe.Offsetof(Dirent{}.Name)) , := direntNamlen()if ! || + > uint64(len()) {break } := [ : +]for , := range {if == 0 { = [:]break } }// Check for useless names before allocating a string.ifstring() == "." || string() == ".." {continue } -- ++ = append(, string()) }return - len(), , }
The pages are generated with Goldsv0.7.3. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.