Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
98bd4dfe
Commit
98bd4dfe
authored
Feb 19, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/io/FileReader: add method Skip()
parent
8e0e4d7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
FileReader.cxx
src/fs/io/FileReader.cxx
+21
-0
FileReader.hxx
src/fs/io/FileReader.hxx
+1
-0
No files found.
src/fs/io/FileReader.cxx
View file @
98bd4dfe
...
...
@@ -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
());
...
...
src/fs/io/FileReader.hxx
View file @
98bd4dfe
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment