Skip to content

Commit b6b8763

Browse files
committed
Fixed seek returns + edited position to use lseek.
1 parent 1ce89e3 commit b6b8763

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: libraries/FS/src/vfs_api.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -434,17 +434,18 @@ bool VFSFileImpl::seek(uint32_t pos, SeekMode mode)
434434
if (res < 0) {
435435
// an error occurred
436436
log_d("FILE SEEK ERROR OCCURED");
437-
return 1; //return error -> for seek its all above 0
437+
return 0; //return error -> for lseek its all above 0
438438
}
439-
return 0; //return success -> for fseek its 0
439+
return 1; //return success -> for fseek its 0
440440
}
441441

442442
size_t VFSFileImpl::position() const
443443
{
444444
if(_isDirectory || !_f) {
445445
return 0;
446446
}
447-
return ftell(_f);
447+
return lseek(fileno(_f), 0, SEEK_CUR);
448+
//return ftell(_f); // old implementation
448449
}
449450

450451
size_t VFSFileImpl::size() const

0 commit comments

Comments
 (0)