chore: initial commit

This commit is contained in:
utox39 committed 2025-02-23 16:55:11 +01:00
commit 9e5f5ef3cf
8 files changed
+206

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
const std = @import("std");
pub fn getUsername(allocator: std.mem.Allocator) ![]u8 {
const username = try std.process.getEnvVarOwned(allocator, "USER");
return username;
}
+6
View File
@@ -0,0 +1,6 @@
const std = @import("std");
pub fn getUsername(allocator: std.mem.Allocator) ![]u8 {
const username = try std.process.getEnvVarOwned(allocator, "USER");
return username;
}
+16
View File
@@ -0,0 +1,16 @@
const std = @import("std");
const os_module = @import("root.zig").os_module;
pub fn main() !void {
const stdout_file = std.io.getStdOut().writer();
var bw = std.io.bufferedWriter(stdout_file);
const stdout = bw.writer();
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
const username = try os_module.getUsername(allocator);
try stdout.print("User: {s}\n", .{username});
try bw.flush();
}
+8
View File
@@ -0,0 +1,8 @@
const std = @import("std");
pub const os_module = switch (@import("builtin").os.tag) {
.linux => @import("linux/linux.zig"),
.macos => @import("macos/macos.zig"),
.windows => @import("windows/windows.zig"),
else => @compileError("Unsupported operating system"),
};
+6
View File
@@ -0,0 +1,6 @@
const std = @import("std");
pub fn getUsername(allocator: std.mem.Allocator) ![]u8 {
const username = try std.process.getEnvVarOwned(allocator, "USERNAME");
return username;
}