diff --git a/zig/src/main.zig b/zig/src/main.zig index 062f801..38c76b0 100644 --- a/zig/src/main.zig +++ b/zig/src/main.zig @@ -2,12 +2,25 @@ //! this project serves to learn zig and test the behaviour of specific features const std = @import("std"); +const fs = std.fs; pub fn main() !void { const stdout = std.io.getStdOut().writer(); - for (1..10) |n| { - try stdout.print("{d} hello world\n", .{n}); + var cwd = try fs.cwd().openDir(".", fs.Dir.OpenOptions{.iterate=true}); + defer cwd.close(); + + var temp = cwd.iterate(); + while (try temp.next()) |item| + { + const properties = try cwd.statFile(item.name); + const item_type = switch (properties.kind) + { + fs.Dir.Entry.Kind.directory => "directory", + fs.Dir.Entry.Kind.file => "file", + else => "other", + }; + try stdout.print("{s} : {s}\n", .{item_type, item.name}); } }