const std = @import("std");
pub fn main() !void {
const path = ".";
const allocator = std.heap.page_allocator;
var dir = try std.fs.cwd().openDir(path, .{ .iterate = true });
defer dir.close();
var walker = try dir.walk(allocator);
defer walker.deinit();
std.debug.print("n", .{});
while (try walker.next()) |entry| {
std.debug.print("File Name: {s}n", .{entry.basename});
}
}
I tried above code which iterate over all current and sub_directories but i don’t want sub-directory iteration.
I am trying below approach and if i don’t pass .iterate = true
i can’t iterate only. How to achieve this
New contributor
prashanthsp is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.