mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:24:49 +01:00
On Windows, it is sometimes problematic to depend on ws2_32.dll. Before, users of std.Io.Threaded would have to call ioBasic() rather than io() in order to avoid unnecessary dependencies on ws2_32.dll. Now, the application can disable networking with std.Options. This change is necessary due to moving networking functionality to be based on Io.Operation, which is a tagged union.
35 lines
894 B
Zig
35 lines
894 B
Zig
//! Verifies that a file exists in a directory.
|
|
//!
|
|
//! Usage:
|
|
//!
|
|
//! ```
|
|
//! exists_in <dir> <path>
|
|
//! ```
|
|
//!
|
|
//! Where `<dir>/<path>` is the full path to the file.
|
|
//! `<dir>` must be an absolute path.
|
|
|
|
const std = @import("std");
|
|
|
|
pub fn main(init: std.process.Init) !void {
|
|
var args = try init.minimal.args.iterateAllocator(init.gpa);
|
|
defer args.deinit();
|
|
_ = args.next() orelse unreachable; // skip binary name
|
|
|
|
const dir_path = args.next() orelse {
|
|
std.log.err("missing <dir> argument", .{});
|
|
return error.BadUsage;
|
|
};
|
|
|
|
const relpath = args.next() orelse {
|
|
std.log.err("missing <path> argument", .{});
|
|
return error.BadUsage;
|
|
};
|
|
|
|
const io = std.Io.Threaded.global_single_threaded.io();
|
|
|
|
var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{});
|
|
defer dir.close(io);
|
|
|
|
_ = try dir.statFile(io, relpath, .{});
|
|
}
|