os:direntNamePtr for array

This commit is contained in:
luoliwoshang
2025-06-26 10:20:16 +08:00
parent f0728c4fe0
commit 417a5692e3
2 changed files with 27 additions and 0 deletions

19
_demo/readdir/main.go Normal file
View File

@@ -0,0 +1,19 @@
package main
import (
"fmt"
"os"
)
func main() {
entries, err := os.ReadDir("../")
if err != nil {
panic(err)
}
if len(entries) == 0 {
panic("No files found")
}
for _, e := range entries {
fmt.Printf("%s isDir[%t]\n", e.Name(), e.IsDir())
}
}

View File

@@ -120,6 +120,14 @@ func direntNamePtr(name any) *byte {
return name
case []byte:
return &name[0]
case [1024]int8:
return (*byte)(unsafe.Pointer(&name[0]))
case [512]int8:
return (*byte)(unsafe.Pointer(&name[0]))
case [256]int8:
return (*byte)(unsafe.Pointer(&name[0]))
case [256]uint8:
return (*byte)(unsafe.Pointer(&name[0]))
default:
panic("invalid type")
}