posix/fd: double check the user has specified binary mode
This commit is contained in:
parent
e7cdb1322a
commit
8c05cf2e1c
@ -27,7 +27,14 @@ fd::fd (const std::experimental::filesystem::path &path, int flags):
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
fd::fd (const std::experimental::filesystem::path &path, int flags, mode_t mode):
|
fd::fd (const std::experimental::filesystem::path &path, int flags, mode_t mode):
|
||||||
m_fd (error::try_value (::open (path.u8string ().c_str (), flags, mode)))
|
m_fd (error::try_value (::open (path.u8string ().c_str (), flags, mode)))
|
||||||
{ ; }
|
{
|
||||||
|
// You always want binary mode. Always.
|
||||||
|
//
|
||||||
|
// But we want the user to have considered this platform issue regardless
|
||||||
|
// so we won't forcibly set the flag, but we will abort the program when
|
||||||
|
// debugging if they've failed to do so.
|
||||||
|
CHECK_EQ (flags & O_BINARY, O_BINARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -23,6 +23,9 @@ namespace cruft::posix {
|
|||||||
class fd {
|
class fd {
|
||||||
public:
|
public:
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// If you are using a system which delineates between binary/text mode
|
||||||
|
// for descriptors the behaviour is undefined if you don't set the
|
||||||
|
// necessary flags for binary mode.
|
||||||
fd (const std::experimental::filesystem::path &path, int flags);
|
fd (const std::experimental::filesystem::path &path, int flags);
|
||||||
fd (const std::experimental::filesystem::path &path, int flags, mode_t);
|
fd (const std::experimental::filesystem::path &path, int flags, mode_t);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user