diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-27 16:37:48 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-27 16:38:44 +0200 |
commit | a292d8cd5a59915ccf4dfdc7fade6066e7d3db14 (patch) | |
tree | 5fce1312f52b30db83ec93a6ae5fcf6f9ef6dbb3 /Libraries/LibCore/CIODevice.cpp | |
parent | be1025c03f6f67898a4a3aeadbb4db6e32694fff (diff) | |
download | serenity-a292d8cd5a59915ccf4dfdc7fade6066e7d3db14.zip |
LibCore: Add CFileStreamReader, a simple streaming CFile reader.
This is extremely barebones right now, but can be used to easily read binary
data from a CFile piece by piece.
Diffstat (limited to 'Libraries/LibCore/CIODevice.cpp')
-rw-r--r-- | Libraries/LibCore/CIODevice.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibCore/CIODevice.cpp b/Libraries/LibCore/CIODevice.cpp index 90f24f8bfe..a585e1a8dd 100644 --- a/Libraries/LibCore/CIODevice.cpp +++ b/Libraries/LibCore/CIODevice.cpp @@ -22,6 +22,13 @@ const char* CIODevice::error_string() const return strerror(m_error); } +int CIODevice::read(u8* buffer, int length) +{ + auto read_buffer = read(length); + memcpy(buffer, read_buffer.data(), length); + return read_buffer.size(); +} + ByteBuffer CIODevice::read(int max_size) { if (m_fd < 0) |