mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
b1d1806fef
In Zig standard library, Dir means an open directory handle. path represents a file system identifier string. This function is better named after "current path" than "current dir". "get" and "working" are superfluous.
17 lines
565 B
Zig
17 lines
565 B
Zig
const std = @import("std");
|
|
|
|
pub fn main(init: std.process.Init) !void {
|
|
const arena = init.arena.allocator();
|
|
const args = try init.minimal.args.toSlice(arena);
|
|
const io = init.io;
|
|
const cwd_path = try std.process.currentPathAlloc(io, arena);
|
|
|
|
if (args.len < 3) return error.MissingArgs;
|
|
|
|
const relative = try std.fs.path.relative(arena, cwd_path, init.environ_map, args[1], args[2]);
|
|
|
|
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
|
|
const stdout = &stdout_writer.interface;
|
|
try stdout.writeAll(relative);
|
|
}
|