posix/fd: add read overloads that take char/byte views
This commit is contained in:
parent
e48aebb503
commit
bfcd63ec65
@ -99,8 +99,17 @@ fd::read (void *buffer, size_t count)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
ssize_t
|
||||
fd::read (util::view<char *> dst)
|
||||
{
|
||||
return read (std::data (dst), std::size (dst));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
ssize_t
|
||||
fd::write (const void *buffer, size_t count)
|
||||
{
|
||||
return error::try_value (
|
||||
|
11
posix/fd.hpp
11
posix/fd.hpp
@ -11,12 +11,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Copyright 2016 Danny Robson <danny@nerdcruft.net>
|
||||
* Copyright 2017 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#ifndef __CRUFT_UTIL_POSIX_FD_HPP
|
||||
#define __CRUFT_UTIL_POSIX_FD_HPP
|
||||
|
||||
#include "../view.hpp"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -52,8 +54,13 @@ namespace util::posix {
|
||||
struct ::stat stat (void) const;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
[[gnu::warn_unused_result]] ssize_t read ( void *buf, size_t count);
|
||||
[[gnu::warn_unused_result]] ssize_t read (void *buf, size_t count);
|
||||
[[gnu::warn_unused_result]] ssize_t read (util::view<char*>);
|
||||
[[gnu::warn_unused_result]] ssize_t read (util::view<std::byte*>);
|
||||
|
||||
[[gnu::warn_unused_result]] ssize_t write (const void *buf, size_t count);
|
||||
[[gnu::warn_unused_result]] ssize_t write (util::view<const char*>);
|
||||
[[gnu::warn_unused_result]] ssize_t write (util::view<const std::byte*>);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
[[gnu::warn_unused_result]] off_t lseek (off_t offset, int whence);
|
||||
|
Loading…
Reference in New Issue
Block a user