I have a directory that is in a tree that is a mounted with sshfs
I use the following to iterate over it:
var idir = try std.fs.cwd().openIterableDir(dir_path, .{});
defer idir.close();
while (try dir_iter.next()) |entry| {
std.debug.print("dbg: {s} {any}\n", .{ entry.name, entry.kind });
....
// opening and reading those files here work just fine
}
now if I run built program once - I see all expected results, such as
Can you provide what operating system you’re on? I’m going to guess some flavor of Linux but there’s some ports to Windows and MacOS that are cluttering up my search attempts.
From the looks of this post, you’re using a version of Zig 11, yes?
the issue seem to be pretty old. Is it even an issue, or an inherited from getdents64 feature?
both would be fine, I just wish that warning from getdents64’s man would also make it into zig’s std lib
Well, I’d definitely say it’s an issue of some sort - can we do something about it? Maybe not. I think this post probably explains why it’s not getting looked into more (from that link):
I think that this, returning Unknown, is a sane default because adding an additional call for each entry in those cases would probably impact performance quite a bit since filesystems without d_type support aren't likely storing that metadata anywhere close.
The common approach seems to be to have an explicit function call on the entry to get the file type that does the stat call if needed.
It looks like there’s some speculation about the performance for something like that (I don’t have a good reason to doubt this from here, but I can’t confirm it either). Looks like another call to stat the file is the most reliable thing to do if you really need that info. Kinda weird though - good question btw.