Skip to content

Commit 4bb475e

Browse files
committed
can use pread & pwrite
1 parent 1883226 commit 4bb475e

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

modules/io/files/littlefs/files-littlefs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ void xs_stat_isDirectory(xsMachine *the)
586586

587587
void xs_stat_isSymbolicLink(xsMachine *the)
588588
{
589-
xsmcGet(xsResult, xsThis, xsID_mode);
590589
xsmcSetFalse(xsResult);
591590
}
592591

modules/io/files/posix/files-posix.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ void xs_fileposix_read(xsMachine *the)
161161
returnLength = 1;
162162
}
163163

164-
throwIf(lseek(fd, position, SEEK_SET));
165-
int result = read(fd, buffer, length);
164+
int result = pread(fd, buffer, length, position);
166165
throwIf(result);
167166

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

182-
throwIf(lseek(fd, position, SEEK_SET));
183-
throwIf(write(fd, buffer, length));
181+
throwIf(pwrite(fd, buffer, length, position));
184182
}
185183

186184
void xs_fileposix_status(xsMachine *the)

0 commit comments

Comments
 (0)