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
dd5daa07
Commit
dd5daa07
authored
Mar 03, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/io/FileReader: add method Seek()
parent
ef5090c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
FileReader.cxx
src/fs/io/FileReader.cxx
+26
-0
FileReader.hxx
src/fs/io/FileReader.hxx
+2
-0
No files found.
src/fs/io/FileReader.cxx
View file @
dd5daa07
...
...
@@ -52,6 +52,19 @@ FileReader::Read(void *data, size_t size, Error &error)
return
nbytes
;
}
bool
FileReader
::
Seek
(
off_t
offset
,
Error
&
error
)
{
assert
(
IsDefined
());
auto
result
=
SetFilePointer
(
handle
,
offset
,
nullptr
,
FILE_BEGIN
);
const
bool
success
=
result
!=
INVALID_SET_FILE_POINTER
;
if
(
!
success
)
error
.
SetLastError
(
"Failed to seek"
);
return
success
;
}
void
FileReader
::
Close
()
{
...
...
@@ -90,6 +103,19 @@ FileReader::Read(void *data, size_t size, Error &error)
return
nbytes
;
}
bool
FileReader
::
Seek
(
off_t
offset
,
Error
&
error
)
{
assert
(
IsDefined
());
auto
result
=
lseek
(
fd
,
offset
,
SEEK_SET
);
const
bool
success
=
result
>=
0
;
if
(
!
success
)
error
.
SetErrno
(
"Failed to seek"
);
return
success
;
}
void
FileReader
::
Close
()
{
...
...
src/fs/io/FileReader.hxx
View file @
dd5daa07
...
...
@@ -61,6 +61,8 @@ public:
void
Close
();
bool
Seek
(
off_t
offset
,
Error
&
error
);
/* virtual methods from class Reader */
size_t
Read
(
void
*
data
,
size_t
size
,
Error
&
error
)
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