fs/io/FileReader: add method Skip()
This commit is contained in:
parent
8e0e4d7c04
commit
98bd4dfe04
@ -65,6 +65,16 @@ FileReader::Seek(off_t offset)
|
||||
throw MakeLastError("Failed to seek");
|
||||
}
|
||||
|
||||
void
|
||||
FileReader::Skip(off_t offset)
|
||||
{
|
||||
assert(IsDefined());
|
||||
|
||||
auto result = SetFilePointer(handle, offset, nullptr, FILE_CURRENT);
|
||||
if (result == INVALID_SET_FILE_POINTER)
|
||||
throw MakeLastError("Failed to seek");
|
||||
}
|
||||
|
||||
void
|
||||
FileReader::Close()
|
||||
{
|
||||
@ -120,6 +130,17 @@ FileReader::Seek(off_t offset)
|
||||
throw MakeErrno("Failed to seek");
|
||||
}
|
||||
|
||||
void
|
||||
FileReader::Skip(off_t offset)
|
||||
{
|
||||
assert(IsDefined());
|
||||
|
||||
auto result = fd.Skip(offset);
|
||||
const bool success = result >= 0;
|
||||
if (!success)
|
||||
throw MakeErrno("Failed to seek");
|
||||
}
|
||||
|
||||
void
|
||||
FileReader::Close()
|
||||
{
|
||||
|
@ -92,6 +92,7 @@ public:
|
||||
FileInfo GetFileInfo() const;
|
||||
|
||||
void Seek(off_t offset);
|
||||
void Skip(off_t offset);
|
||||
|
||||
/* virtual methods from class Reader */
|
||||
size_t Read(void *data, size_t size) override;
|
||||
|
Loading…
Reference in New Issue
Block a user