mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
os: passwd also gets username
This commit is contained in:
@ -26,6 +26,7 @@ const c = if (builtin.os.tag != .windows) @cImport({
|
|||||||
pub const Entry = struct {
|
pub const Entry = struct {
|
||||||
shell: ?[]const u8 = null,
|
shell: ?[]const u8 = null,
|
||||||
home: ?[]const u8 = null,
|
home: ?[]const u8 = null,
|
||||||
|
name: ?[]const u8 = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Get the passwd entry for the currently executing user.
|
/// Get the passwd entry for the currently executing user.
|
||||||
@ -134,6 +135,13 @@ pub fn get(alloc: Allocator) !Entry {
|
|||||||
result.home = dir;
|
result.home = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pw.pw_name) |ptr| {
|
||||||
|
const source = std.mem.sliceTo(ptr, 0);
|
||||||
|
const name = try alloc.alloc(u8, source.len);
|
||||||
|
@memcpy(name, source);
|
||||||
|
result.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user