From 07e2de981afa75c2884bf577a438c3c7e7805dec Mon Sep 17 00:00:00 2001 From: Alice Date: Mon, 13 Jan 2020 15:44:04 +0100 Subject: [PATCH] core: add BFile_Size syscall --- include/gint/bfile.h | 6 ++++++ src/core/syscalls.S | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/include/gint/bfile.h b/include/gint/bfile.h index 4360b81..242ec1a 100644 --- a/include/gint/bfile.h +++ b/include/gint/bfile.h @@ -52,6 +52,12 @@ int BFile_Open(uint16_t const *file, enum BFile_OpenMode mode); Returns a BFile error code. */ int BFile_Close(int fd); +/* BFile_Size(): Retrieve size of an open file + + @fd File descriptor + Returns the file size in bytes, or a negative BFile error code*/ +int BFile_Size(int fd); + /* BFile_Write(): Write data to an open file Second and third argument specify the data and length to write. diff --git a/src/core/syscalls.S b/src/core/syscalls.S index 8c9f9a0..cbf1068 100644 --- a/src/core/syscalls.S +++ b/src/core/syscalls.S @@ -23,6 +23,7 @@ .global _BFile_Create .global _BFile_Open .global _BFile_Close +.global _BFile_Size .global _BFile_Write .global _BFile_Read @@ -71,6 +72,10 @@ _BFile_Open: _BFile_Close: syscall(0x042d) +# int BFile_Size(int handle) +_BFile_Size: + syscall(0x042f) + # int BFile_Write(int handle, const void *ram_buffer, int even_size) _BFile_Write: syscall(0x0435)