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


C++ path_type::parent_path方法代码示例

本文整理汇总了C++中path_type::parent_path方法的典型用法代码示例。如果您正苦于以下问题:C++ path_type::parent_path方法的具体用法?C++ path_type::parent_path怎么用?C++ path_type::parent_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在path_type的用法示例。


在下文中一共展示了path_type::parent_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: open_file

bool slice_reader::open_file(const path_type & file) {
	
	log_info << "Opening \"" << color::cyan << file.string() << color::reset << '"';
	
	ifs.close();
	ifs.clear();
	
	ifs.open(file, std::ios_base::in | std::ios_base::binary | std::ios_base::ate);
	if(ifs.fail()) {
		return false;
	}
	
	std::streampos file_size = ifs.tellg();
	ifs.seekg(0);
	
	char magic[8];
	if(ifs.read(magic, 8).fail()) {
		ifs.close();
		throw slice_error("could not read slice magic number in \"" + file.string() + "\"");
	}
	bool found = false;
	for(size_t i = 0; boost::size(slice_ids); i++) {
		if(!std::memcmp(magic, slice_ids[i], 8)) {
			found = true;
			break;
		}
	}
	if(!found) {
		ifs.close();
		throw slice_error("bad slice magic number in \"" + file.string() + "\"");
	}
	
	slice_size = util::load<boost::uint32_t>(ifs);
	if(ifs.fail()) {
		ifs.close();
		throw slice_error("could not read slice size in \"" + file.string() + "\"");
	} else if(std::streampos(slice_size) > file_size) {
		ifs.close();
		std::ostringstream oss;
		oss << "bad slice size in " << file << ": " << slice_size << " > " << file_size;
		throw slice_error(oss.str());
	} else if(std::streampos(slice_size) < ifs.tellg()) {
		ifs.close();
		std::ostringstream oss;
		oss << "bad slice size in " << file << ": " << slice_size << " < " << ifs.tellg();
		throw slice_error(oss.str());
	}
	
	slice_file = file;
	
	last_dir = file.parent_path();
	
	return true;
}
开发者ID:4nh51rk,项目名称:innoextract,代码行数:54,代码来源:slice.cpp

示例2: match_path

 bool server_type::match_path(path_type const& path, file_type type)
 {
     return  type == file_type::regular_file &&
             path.parent_path() == "/tcp" &&
             path.filename().string()[0] == '*';
 }
开发者ID:carriercomm,项目名称:fuse_planetfs,代码行数:6,代码来源:server_op.cpp


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