本文整理汇总了C++中platform::ThrowFileOperationFailure方法的典型用法代码示例。如果您正苦于以下问题:C++ platform::ThrowFileOperationFailure方法的具体用法?C++ platform::ThrowFileOperationFailure怎么用?C++ platform::ThrowFileOperationFailure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platform
的用法示例。
在下文中一共展示了platform::ThrowFileOperationFailure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: h_read
pair<UniqueHandle, UniqueHandle>
MakePipe()
{
# if YCL_Win32
::HANDLE h_raw_read, h_raw_write;
YCL_CallWin32F(CreatePipe, &h_raw_read, &h_raw_write, {}, 0);
UniqueHandle h_read(h_raw_read), h_write(h_raw_write);
YCL_CallWin32F(SetHandleInformation, h_write.get(), HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT);
return {std::move(h_read), std::move(h_write)};
# elif YCL_API_Has_unistd_h
int fds[2];
// TODO: Check whether '::socketpair' is available.
if(::pipe(fds) != 0)
ThrowFileOperationFailure("Failed getting file size.");
auto pr(make_pair(UniqueHandle(fds[0]), UniqueHandle(fds[1])));
auto check([](UniqueHandle& h, const char* msg){
// NOTE: %O_NONBLOCK is initially cleared on ::pipe results.
// See http://pubs.opengroup.org/onlinepubs/9699919799/.
if(!(h && h->SetNonblocking()))
ThrowFileOperationFailure(msg);
});
check(pr.first, "Failed making pipe for reading."),
check(pr.second, "Failed making pipe for writing.");
return pr;
# else
# error "Unsupported platform found."
# endif
}