feat(windows): WIP

This commit is contained in:
utox39
2025-04-03 02:30:42 +02:00
parent f5d347c92f
commit 5eed155d70
2 changed files with 13 additions and 11 deletions

View File

@@ -3,6 +3,6 @@ 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"),
.windows => @compileError("Windows: WIP"),
else => @compileError("Unsupported operating system"),
};

View File

@@ -1,15 +1,17 @@
const std = @import("std");
pub fn getUsername(allocator: std.mem.Allocator) ![]u8 {
const username = try std.process.getEnvVarOwned(allocator, "USERNAME");
return username;
}
// TODO: (2) WIP
pub fn getHostname(allocator: std.mem.Allocator) ![]u8 {
var buf: [std.posix.HOST_NAME_MAX]u8 = undefined;
const hostnameEnv = try std.posix.gethostname(&buf);
// pub fn getUsername(allocator: std.mem.Allocator) ![]u8 {
// const username = try std.process.getEnvVarOwned(allocator, "USERNAME");
// return username;
// }
const hostname = try allocator.dupe(u8, hostnameEnv);
// pub fn getHostname(allocator: std.mem.Allocator) ![]u8 {
// var buf: [std.posix.HOST_NAME_MAX]u8 = undefined;
// const hostnameEnv = try std.posix.gethostname(&buf);
return hostname;
}
// const hostname = try allocator.dupe(u8, hostnameEnv);
// return hostname;
// }