1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

LibCore: Let offset-related Stream functions return an unsigned value

A negative return value doesn't make sense for any of those functions.
The return types were inherited from POSIX, where they also need to have
an indicator for an error (negative values).
This commit is contained in:
Tim Schumacher 2023-01-17 14:52:46 +01:00 committed by Jelle Raaijmakers
parent 1ca62de558
commit daf181caa8
5 changed files with 32 additions and 32 deletions

View file

@ -108,14 +108,14 @@ ErrorOr<void> Stream::write_entire_buffer(ReadonlyBytes buffer)
return {};
}
ErrorOr<off_t> SeekableStream::tell() const
ErrorOr<size_t> SeekableStream::tell() const
{
// Seek with 0 and SEEK_CUR does not modify anything despite the const_cast,
// so it's safe to do this.
return const_cast<SeekableStream*>(this)->seek(0, SeekMode::FromCurrentPosition);
}
ErrorOr<off_t> SeekableStream::size()
ErrorOr<size_t> SeekableStream::size()
{
auto original_position = TRY(tell());
@ -280,7 +280,7 @@ void File::close()
m_fd = -1;
}
ErrorOr<off_t> File::seek(i64 offset, SeekMode mode)
ErrorOr<size_t> File::seek(i64 offset, SeekMode mode)
{
int syscall_mode;
switch (mode) {
@ -297,7 +297,7 @@ ErrorOr<off_t> File::seek(i64 offset, SeekMode mode)
VERIFY_NOT_REACHED();
}
off_t seek_result = TRY(System::lseek(m_fd, offset, syscall_mode));
size_t seek_result = TRY(System::lseek(m_fd, offset, syscall_mode));
m_last_read_was_eof = false;
return seek_result;
}