Commit 98bd4dfe authored by Max Kellermann's avatar Max Kellermann

fs/io/FileReader: add method Skip()

parent 8e0e4d7c
......@@ -66,6 +66,16 @@ FileReader::Seek(off_t offset)
}
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()
{
assert(IsDefined());
......@@ -121,6 +131,17 @@ FileReader::Seek(off_t offset)
}
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()
{
assert(IsDefined());
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment