mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-08 08:38:51 +00:00
os2: skip . and .. in read dir
This commit is contained in:
@@ -17,6 +17,7 @@ _read_directory_iterator :: proc(it: ^Read_Directory_Iterator) -> (fi: File_Info
|
||||
index = it.impl.idx
|
||||
it.impl.idx += 1
|
||||
|
||||
for {
|
||||
entry := posix.readdir(it.impl.dir)
|
||||
if entry == nil {
|
||||
// NOTE(laytan): would be good to have an `error` field on the `Read_Directory_Iterator`
|
||||
@@ -25,11 +26,9 @@ _read_directory_iterator :: proc(it: ^Read_Directory_Iterator) -> (fi: File_Info
|
||||
}
|
||||
|
||||
cname := cstring(raw_data(entry.d_name[:]))
|
||||
|
||||
// NOTE: these shouldn't be given back, but how?
|
||||
// if cname == "." || cname == ".." {
|
||||
// continue
|
||||
// }
|
||||
if cname == "." || cname == ".." {
|
||||
continue
|
||||
}
|
||||
|
||||
stat: posix.stat_t
|
||||
if posix.fstatat(posix.dirfd(it.impl.dir), cname, &stat, { .SYMLINK_NOFOLLOW }) != .OK {
|
||||
@@ -48,6 +47,7 @@ _read_directory_iterator :: proc(it: ^Read_Directory_Iterator) -> (fi: File_Info
|
||||
ok = true
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
_read_directory_iterator_create :: proc(f: ^File) -> (iter: Read_Directory_Iterator, err: Error) {
|
||||
|
||||
Reference in New Issue
Block a user