mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +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
|
index = it.impl.idx
|
||||||
it.impl.idx += 1
|
it.impl.idx += 1
|
||||||
|
|
||||||
|
for {
|
||||||
entry := posix.readdir(it.impl.dir)
|
entry := posix.readdir(it.impl.dir)
|
||||||
if entry == nil {
|
if entry == nil {
|
||||||
// NOTE(laytan): would be good to have an `error` field on the `Read_Directory_Iterator`
|
// 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[:]))
|
cname := cstring(raw_data(entry.d_name[:]))
|
||||||
|
if cname == "." || cname == ".." {
|
||||||
// NOTE: these shouldn't be given back, but how?
|
continue
|
||||||
// if cname == "." || cname == ".." {
|
}
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
|
|
||||||
stat: posix.stat_t
|
stat: posix.stat_t
|
||||||
if posix.fstatat(posix.dirfd(it.impl.dir), cname, &stat, { .SYMLINK_NOFOLLOW }) != .OK {
|
if posix.fstatat(posix.dirfd(it.impl.dir), cname, &stat, { .SYMLINK_NOFOLLOW }) != .OK {
|
||||||
@@ -47,6 +46,7 @@ _read_directory_iterator :: proc(it: ^Read_Directory_Iterator) -> (fi: File_Info
|
|||||||
fi = internal_stat(stat, string(it.impl.fullpath[:n]))
|
fi = internal_stat(stat, string(it.impl.fullpath[:n]))
|
||||||
ok = true
|
ok = true
|
||||||
return
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@(require_results)
|
@(require_results)
|
||||||
|
|||||||
Reference in New Issue
Block a user