diff options
Diffstat (limited to 'system.old/libraries/io/location.zig')
| -rw-r--r-- | system.old/libraries/io/location.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/system.old/libraries/io/location.zig b/system.old/libraries/io/location.zig new file mode 100644 index 0000000..0f1e114 --- /dev/null +++ b/system.old/libraries/io/location.zig @@ -0,0 +1,30 @@ +//! Location operations + +const sys = @import("sys"); +const types = @import("types.zig"); + +const ERROR_RESULT: u64 = @bitCast(@as(i64, -1)); + +pub fn get(buffer: []u8) types.Error![]u8 { + const result = sys.syscall(.getlocation, .{ + @intFromPtr(buffer.ptr), + buffer.len, + }); + + if (result == ERROR_RESULT) { + return types.Error.GetLocationFailed; + } + + return buffer[0..@intCast(result)]; +} + +pub fn set(location: []const u8) types.Error!void { + const result = sys.syscall(.setlocation, .{ + @intFromPtr(location.ptr), + location.len, + }); + + if (result == ERROR_RESULT) { + return types.Error.InvalidLocation; + } +} |
