52 m_handle = {CreateFile(file.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
nullptr)};
53 if(m_handle == INVALID_HANDLE_VALUE)
55 Term::Private::WindowsError().
check_if((m_handle = CreateFile(
"NUL", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
nullptr)) == INVALID_HANDLE_VALUE).
throw_exception(
"Problem opening NUL");
61 std::size_t flag{O_ASYNC | O_DSYNC | O_NOCTTY | O_SYNC | O_NDELAY};
62 flag &= ~static_cast<std::size_t>(O_NONBLOCK);
63 if(mode.find(
'r') != std::string::npos) { flag |= O_RDONLY; }
64 else if(mode.find(
'w') != std::string::npos) { flag |= O_WRONLY; }
65 else { flag |= O_RDWR; }
66 m_fd = {::open(file.c_str(),
static_cast<int>(flag))};
131 std::string ret(4096,
'\0');
133 ReadConsole(
Private::in.handle(), &ret[0],
static_cast<DWORD
>(ret.size()), &nread,
nullptr);
136 #if defined(MAX_INPUT)
137 static const constexpr std::size_t max_input{MAX_INPUT};
139 static const constexpr std::size_t max_input{256};
141 #if defined(_POSIX_MAX_INPUT)
142 static const constexpr std::size_t posix_max_input{_POSIX_MAX_INPUT};
144 static const constexpr std::size_t posix_max_input{256};
146 static std::size_t nread{std::max(max_input, posix_max_input)};
148 std::string ret(nread,
'\0');