This commit is contained in:
Laytan Laats
2024-12-01 11:54:52 +11:00
committed by flysand7
parent 6866e69cb9
commit 9adc7f2bcf
+14 -14
View File
@@ -32,10 +32,10 @@ foreign lib {
defer posix.free(list) defer posix.free(list)
entries := list[:ret] entries := list[:ret]
for entry in entries { for entry in entries {
log.info(entry) log.info(entry)
posix.free(entry) posix.free(entry)
} }
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/scandir.html ]] [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/scandir.html ]]
*/ */
@@ -90,16 +90,16 @@ foreign lib {
Returns nil when the end is reached or an error occurred (which sets errno). Returns nil when the end is reached or an error occurred (which sets errno).
Example: Example:
posix.set_errno(.NONE) posix.set_errno(.NONE)
entry := posix.readdir(dirp) entry := posix.readdir(dirp)
if entry == nil { if entry == nil {
if errno := posix.errno(); errno != .NONE { if errno := posix.errno(); errno != .NONE {
panic(string(posix.strerror(errno))) panic(string(posix.strerror(errno)))
} else { } else {
fmt.println("end of directory stream") fmt.println("end of directory stream")
} }
} else { } else {
fmt.println(entry) fmt.println(entry)
} }
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html ]] [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html ]]