1//! Verifies that a file exists in a directory.
2//!
3//! Usage:
4//!
5//! ```
6//! exists_in <dir> <path>
7//! ```
8//!
9//! Where `<dir>/<path>` is the full path to the file.
10//! `<dir>` must be an absolute path.
11
12const std = @import("std");
13
14pub fn main(init: std.process.Init) !void {
15 var args = try init.minimal.args.iterateAllocator(init.gpa);
16 defer args.deinit();
17 _ = args.next() orelse unreachable; // skip binary name
18
19 const dir_path = args.next() orelse {
20 std.log.err("missing <dir> argument", .{});
21 return error.BadUsage;
22 };
23
24 const relpath = args.next() orelse {
25 std.log.err("missing <path> argument", .{});
26 return error.BadUsage;
27 };
28
29 const io = std.Io.Threaded.global_single_threaded.io();
30
31 var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{});
32 defer dir.close(io);
33
34 _ = try dir.statFile(io, relpath, .{});
35}