Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: use fseeko() and ftello() #162

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down