summaryrefslogtreecommitdiffhomepage
path: root/lib/fs.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2023-07-12 15:50:44 +0200
committerGitHub <noreply@github.com>2023-07-12 15:50:44 +0200
commitb33791791f947f95ce8721d11b66965d372b507d (patch)
tree112cb1a13989ded62fc94e5b22728c3daf8d0d35 /lib/fs.c
parentf9260f7d93af53ff5725e55b5bb2982d1648c8ff (diff)
parentf0cc841a456bb2d1f04f96ee5962f165f1bfd1c8 (diff)
Merge pull request #162 from jow-/fs-ftello-fseeko
fs: use `fseeko()` and `ftello()`
Diffstat (limited to 'lib/fs.c')
-rw-r--r--lib/fs.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/fs.c b/lib/fs.c
index 8b11d3d..bd053f2 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -651,7 +651,7 @@ uc_fs_seek(uc_vm_t *vm, size_t nargs)
uc_value_t *ofs = uc_fn_arg(0);
uc_value_t *how = uc_fn_arg(1);
int whence, res;
- long offset;
+ off_t offset;
FILE **fp = uc_fn_this("fs.file");
@@ -663,7 +663,7 @@ uc_fs_seek(uc_vm_t *vm, size_t nargs)
else if (ucv_type(ofs) != UC_INTEGER)
err_return(EINVAL);
else
- offset = (long)ucv_int64_get(ofs);
+ offset = (off_t)ucv_int64_get(ofs);
if (!how)
whence = 0;
@@ -672,7 +672,7 @@ uc_fs_seek(uc_vm_t *vm, size_t nargs)
else
whence = (int)ucv_int64_get(how);
- res = fseek(*fp, offset, whence);
+ res = fseeko(*fp, offset, whence);
if (res < 0)
err_return(errno);
@@ -683,14 +683,14 @@ uc_fs_seek(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_tell(uc_vm_t *vm, size_t nargs)
{
- long offset;
+ off_t offset;
FILE **fp = uc_fn_this("fs.file");
if (!fp || !*fp)
err_return(EBADF);
- offset = ftell(*fp);
+ offset = ftello(*fp);
if (offset < 0)
err_return(errno);