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
8748b2dc
Commit
8748b2dc
authored
Aug 16, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/io/BufferedReader: add ReadFull(size_t)
parent
5f66af37
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
BufferedReader.cxx
src/fs/io/BufferedReader.cxx
+13
-0
BufferedReader.hxx
src/fs/io/BufferedReader.hxx
+8
-0
No files found.
src/fs/io/BufferedReader.cxx
View file @
8748b2dc
...
...
@@ -53,6 +53,19 @@ BufferedReader::Fill(bool need_more)
return
true
;
}
void
*
BufferedReader
::
ReadFull
(
size_t
size
)
{
while
(
true
)
{
auto
r
=
Read
();
if
(
r
.
size
>=
size
)
return
r
.
data
;
if
(
!
Fill
(
true
))
throw
std
::
runtime_error
(
"Premature end of file"
);
}
}
size_t
BufferedReader
::
ReadFromBuffer
(
WritableBuffer
<
void
>
dest
)
{
...
...
src/fs/io/BufferedReader.hxx
View file @
8748b2dc
...
...
@@ -51,6 +51,14 @@ public:
return
buffer
.
Read
().
ToVoid
();
}
/**
* Read a buffer of exactly the given size (without consuming
* it). Throws std::runtime_error if not enough data is
* available.
*/
gcc_pure
void
*
ReadFull
(
size_t
size
);
void
Consume
(
size_t
n
)
{
buffer
.
Consume
(
n
);
}
...
...
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