mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-08 06:44:27 +00:00
Tests that fs.selfExePath follows symlinks by comparing it to the path of the File returned from fs.openSelfExe
15 lines
529 B
Zig
15 lines
529 B
Zig
const std = @import("std");
|
|
|
|
pub fn main() anyerror!void {
|
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
defer if (gpa.deinit() == .leak) @panic("found memory leaks");
|
|
const allocator = gpa.allocator();
|
|
|
|
var it = try std.process.argsWithAllocator(allocator);
|
|
defer it.deinit();
|
|
_ = it.next() orelse unreachable; // skip binary name
|
|
const exe_path = it.next() orelse unreachable;
|
|
const symlink_path = it.next() orelse unreachable;
|
|
|
|
try std.fs.cwd().symLink(exe_path, symlink_path, .{});
|
|
}
|