lseek: let the host OS set lseek errors (#2370)

* Fix lseek(fd, -1, SEEK_SET) for XNA

* be sure, if seek really return error

* refactoring

* let host os set lseek errors
This commit is contained in:
mailwl 2025-03-24 16:51:36 +03:00 committed by GitHub
parent 16a68d78eb
commit 1908d26093
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 14 deletions

View file

@ -377,20 +377,6 @@ bool IOFile::Seek(s64 offset, SeekOrigin origin) const {
return false;
}
if (False(file_access_mode & (FileAccessMode::Write | FileAccessMode::Append))) {
u64 size = GetSize();
if (origin == SeekOrigin::CurrentPosition && Tell() + offset > size) {
LOG_ERROR(Common_Filesystem, "Seeking past the end of the file");
return false;
} else if (origin == SeekOrigin::SetOrigin && (u64)offset > size) {
LOG_ERROR(Common_Filesystem, "Seeking past the end of the file");
return false;
} else if (origin == SeekOrigin::End && offset > 0) {
LOG_ERROR(Common_Filesystem, "Seeking past the end of the file");
return false;
}
}
errno = 0;
const auto seek_result = fseeko(file, offset, ToSeekOrigin(origin)) == 0;