Skip to content

Commit

Permalink
can use pread & pwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
phoddie committed May 9, 2024
1 parent 1883226 commit 4bb475e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
1 change: 0 additions & 1 deletion modules/io/files/littlefs/files-littlefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,6 @@ void xs_stat_isDirectory(xsMachine *the)

void xs_stat_isSymbolicLink(xsMachine *the)
{
xsmcGet(xsResult, xsThis, xsID_mode);
xsmcSetFalse(xsResult);
}

Expand Down
6 changes: 2 additions & 4 deletions modules/io/files/posix/files-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ void xs_fileposix_read(xsMachine *the)
returnLength = 1;
}

throwIf(lseek(fd, position, SEEK_SET));
int result = read(fd, buffer, length);
int result = pread(fd, buffer, length, position);
throwIf(result);

if (returnLength)
Expand All @@ -179,8 +178,7 @@ void xs_fileposix_write(xsMachine *the)
xsUnsignedValue length;
xsmcGetBufferWritable(xsArg(0), &buffer, &length);

throwIf(lseek(fd, position, SEEK_SET));
throwIf(write(fd, buffer, length));
throwIf(pwrite(fd, buffer, length, position));
}

void xs_fileposix_status(xsMachine *the)
Expand Down

0 comments on commit 4bb475e

Please sign in to comment.