本文整理汇总了C++中OutputStream::open方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputStream::open方法的具体用法?C++ OutputStream::open怎么用?C++ OutputStream::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputStream
的用法示例。
在下文中一共展示了OutputStream::open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hdfsOpenFile
hdfsFile hdfsOpenFile(hdfsFS fs, const char * path, int flags, int bufferSize,
short replication, tOffset blocksize) {
PARAMETER_ASSERT(fs && path && strlen(path) > 0, NULL, EINVAL);
PARAMETER_ASSERT(bufferSize >= 0 && replication >= 0 && blocksize >= 0, NULL, EINVAL);
PARAMETER_ASSERT(!(flags & O_RDWR) && !((flags & O_EXCL) && (flags & O_CREAT)), NULL, ENOTSUP);
HdfsFileInternalWrapper * file = NULL;
OutputStream * os = NULL;
InputStream * is = NULL;
try {
file = new HdfsFileInternalWrapper();
if ((flags & O_CREAT) || (flags & O_APPEND) || (flags & O_WRONLY)) {
int internalFlags = 0;
if (flags & O_CREAT) {
internalFlags |= Hdfs::Create;
} else if ((flags & O_APPEND) && (flags & O_WRONLY)) {
internalFlags |= Hdfs::Create;
internalFlags |= Hdfs::Append;
} else if (flags & O_WRONLY) {
internalFlags |= Hdfs::Create;
internalFlags |= Hdfs::Overwrite;
}
if (flags & O_SYNC) {
internalFlags |= Hdfs::SyncBlock;
}
file->setInput(false);
os = new OutputStream;
os->open(fs->getFilesystem(), path, internalFlags, 0777, false, replication,
blocksize);
file->setStream(os);
} else {
file->setInput(true);
is = new InputStream;
is->open(fs->getFilesystem(), path, true);
file->setStream(is);
}
return file;
} catch (const std::bad_alloc & e) {
delete file;
delete os;
delete is;
SetErrorMessage("Out of memory");
errno = ENOMEM;
} catch (...) {
delete file;
delete os;
delete is;
SetLastException(Hdfs::current_exception());
handleException(Hdfs::current_exception());
}
return NULL;
}