os:direntNamePtr for array
This commit is contained in:
19
_demo/readdir/main.go
Normal file
19
_demo/readdir/main.go
Normal 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())
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user