当前位置: 首页>>代码示例>>C++>>正文


C++ path::has_branch_path方法代码示例

本文整理汇总了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
    }
开发者ID:3rf,项目名称:mongo,代码行数:45,代码来源:paths.cpp


注:本文中的boost::filesystem::path::has_branch_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。