diff --git a/src/platform/platform_io.h b/src/platform/platform_io.h index 763447b..0cdcd8d 100644 --- a/src/platform/platform_io.h +++ b/src/platform/platform_io.h @@ -43,7 +43,6 @@ enum IO_OP_FSTAT, - IO_OP_POS, IO_OP_SEEK, IO_OP_READ, IO_OP_WRITE, diff --git a/src/platform/platform_io_common.c b/src/platform/platform_io_common.c index af7d0d2..1fd314d 100644 --- a/src/platform/platform_io_common.c +++ b/src/platform/platform_io_common.c @@ -33,15 +33,6 @@ void file_close(file_handle file) io_wait_single_req(&req); } -i64 file_pos(file_handle file) -{ - io_req req = {.op = IO_OP_POS, - .handle = file}; - - io_cmp cmp = io_wait_single_req(&req); - return(cmp.offset); -} - i64 file_seek(file_handle file, i64 offset, file_whence whence) { io_req req = {.op = IO_OP_SEEK, @@ -53,6 +44,11 @@ i64 file_seek(file_handle file, i64 offset, file_whence whence) return(cmp.offset); } +i64 file_pos(file_handle file) +{ + return(file_seek(file, 0, FILE_SEEK_CURRENT)); +} + u64 file_write(file_handle file, u64 size, char* buffer) { io_req req = {.op = IO_OP_WRITE, diff --git a/src/platform/posix_io.c b/src/platform/posix_io.c index da429a9..12cff2d 100644 --- a/src/platform/posix_io.c +++ b/src/platform/posix_io.c @@ -364,19 +364,6 @@ io_cmp io_fstat(file_slot* slot, io_req* req) return(cmp); } -io_cmp io_pos(file_slot* slot, io_req* req) -{ - io_cmp cmp = {0}; - cmp.result = lseek(slot->fd, 0, SEEK_CUR); - if(cmp.result < 0) - { - slot->error = io_convert_errno(errno); - cmp.error = slot->error; - } - - return(cmp); -} - io_cmp io_seek(file_slot* slot, io_req* req) { io_cmp cmp = {0}; @@ -484,10 +471,6 @@ io_cmp io_wait_single_req(io_req* req) cmp = io_write(slot, req); break; - case IO_OP_POS: - cmp = io_pos(slot, req); - break; - case IO_OP_SEEK: cmp = io_seek(slot, req); break; diff --git a/src/platform/win32_io.c b/src/platform/win32_io.c index 2ca2896..c14cdd5 100644 --- a/src/platform/win32_io.c +++ b/src/platform/win32_io.c @@ -320,24 +320,6 @@ io_cmp io_fstat(file_slot* slot, io_req* req) return(cmp); } -io_cmp io_pos(file_slot* slot, io_req* req) -{ - io_cmp cmp = {0}; - LARGE_INTEGER off = {.QuadPart = req->offset}; - LARGE_INTEGER newPos = {0}; - - if(!SetFilePointerEx(slot->h, off, &newPos, FILE_CURRENT)) - { - slot->error = io_convert_win32_error(GetLastError()); - cmp.error = slot->error; - } - else - { - cmp.result = newPos.QuadPart; - } - return(cmp); -} - io_cmp io_seek(file_slot* slot, io_req* req) { io_cmp cmp = {0}; @@ -460,10 +442,6 @@ io_cmp io_wait_single_req(io_req* req) cmp = io_write(slot, req); break; - case IO_OP_POS: - cmp = io_pos(slot, req); - break; - case IO_OP_SEEK: cmp = io_seek(slot, req); break;