本文整理汇总了C++中boost::filesystem::path::has_branch_path方法的典型用法代码示例。如果您正苦于以下问题:C++ path::has_branch_path方法的具体用法?C++ path::has_branch_path怎么用?C++ path::has_branch_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::has_branch_path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flushMyDirectory
void flushMyDirectory(const boost::filesystem::path& file) {
#ifdef __linux__ // this isn't needed elsewhere
static bool _warnedAboutFilesystem = false;
// if called without a fully qualified path it asserts; that makes mongoperf fail.
// so make a warning. need a better solution longer term.
// massert(13652, str::stream() << "Couldn't find parent dir for file: " << file.string(),);
if (!file.has_branch_path()) {
log() << "warning flushMyDirectory couldn't find parent dir for file: "
<< file.string();
return;
}
boost::filesystem::path dir = file.branch_path(); // parent_path in new boosts
LOG(1) << "flushing directory " << dir.string();
int fd = ::open(dir.string().c_str(), O_RDONLY); // DO NOT THROW OR ASSERT BEFORE CLOSING
massert(13650, str::stream() << "Couldn't open directory '" << dir.string()
<< "' for flushing: " << errnoWithDescription(),
fd >= 0);
if (fsync(fd) != 0) {
int e = errno;
if (e == EINVAL) { // indicates filesystem does not support synchronization
if (!_warnedAboutFilesystem) {
log() << "\tWARNING: This file system is not supported. For further information"
<< " see:"
<< startupWarningsLog;
log() << "\t\t\thttp://dochub.mongodb.org/core/unsupported-filesystems"
<< startupWarningsLog;
log() << "\t\tPlease notify MongoDB, Inc. if an unlisted filesystem generated "
<< "this warning." << startupWarningsLog;
_warnedAboutFilesystem = true;
}
}
else {
close(fd);
massert(13651, str::stream() << "Couldn't fsync directory '" << dir.string()
<< "': " << errnoWithDescription(e),
false);
}
}
close(fd);
#endif
}