Skip to content

Commit 03c28a7

Browse files
committed
debug
1 parent 2ae20ae commit 03c28a7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

examples/zigcrypto_test.zig

+35
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,41 @@ pub fn main() anyerror!void {
2424
debug.assert(result == sqlite.c.SQLITE_OK);
2525
}
2626

27+
{
28+
const Context = struct {
29+
dir: std.fs.Dir,
30+
indent: usize,
31+
};
32+
33+
var stack = std.ArrayList(Context).init(allocator);
34+
try stack.append(.{
35+
.dir = try std.fs.cwd().openDir(".", .{
36+
.iterate = true,
37+
}),
38+
.indent = 0,
39+
});
40+
41+
while (stack.pop()) |ctx| {
42+
var iter = ctx.dir.iterate();
43+
44+
while (try iter.next()) |entry| {
45+
const indent = try allocator.alloc(u8, ctx.indent);
46+
@memset(indent, ' ');
47+
48+
std.debug.print("{s}entry: {s}\n", .{ indent, entry.name });
49+
switch (entry.kind) {
50+
.directory => try stack.append(.{
51+
.dir = try ctx.dir.openDir(entry.name, .{
52+
.iterate = true,
53+
}),
54+
.indent = ctx.indent + 1,
55+
}),
56+
else => {},
57+
}
58+
}
59+
}
60+
}
61+
2762
{
2863
const extension_path = if (builtin.os.tag == .windows)
2964
"./zig-out/bin/zigcrypto.dll"

0 commit comments

Comments
 (0)