1 Commits

Author SHA1 Message Date
宋文武
24d245c09b programs: Add Uxn emulator.
Some checks failed
Build system / Check kernel codestyle (pull_request) Has been cancelled
Build system / Build (pull_request) Has been cancelled
2025-07-20 21:52:12 +08:00
2 changed files with 1 additions and 16 deletions

View File

@@ -538,20 +538,6 @@ pub fn writeFile(pathname: [*:0]const u8, offset: u64, buffer: []u8) !u32 {
};
}
pub fn fileGetSize(pathname: [*:0]const u8) !u64 {
var ret: [10]u32 = undefined;
const info: FileInfo = .{
.subfn = 5,
.offset = 0,
.size = 0,
.buffer = @intFromPtr(&ret),
.pathptr = @ptrCast(pathname),
};
if (syscall1(SYS.file, @intFromPtr(&info)) != 0)
return error.Unexpected;
return ret[8] | (@as(u64, ret[9]) << 32);
}
pub fn deleteFile(pathname: [*:0]const u8) !void {
const info: FileInfo = .{
.subfn = 8,

View File

@@ -98,8 +98,7 @@ const emu = struct {
const buffer = getFilePortSlice(dev, ports.write);
var ret: u32 = 0;
if (append) {
const offset: u32 = @intCast(kos.fileGetSize(pathname) catch 0);
ret = kos.writeFile(pathname, offset, buffer) catch |err| blk: {
ret = kos.writeFile(pathname, file_offsets[idx], buffer) catch |err| blk: {
if (err == error.FileNotFound) {
break :blk kos.createFile(pathname, buffer) catch 0;
} else {