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


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

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


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

示例1: file_error

	boost::shared_ptr<file> file_pool::open_file(void* st, fs::path const& p, file::open_mode m)
	{
		assert(st != 0);
		assert(p.is_complete());
		assert(m == file::in || m == (file::in | file::out));
		boost::mutex::scoped_lock l(m_mutex);
		typedef nth_index<file_set, 0>::type path_view;
		path_view& pt = get<0>(m_files);
		path_view::iterator i = pt.find(p);
		if (i != pt.end())
		{
			lru_file_entry e = *i;
			e.last_use = time_now();

			if (e.key != st)
			{
				// this means that another instance of the storage
				// is using the exact same file.
				throw file_error("torrent uses the same file as another torrent "
					"(" + p.string() + ")");
			}

			e.key = st;
			if ((e.mode & m) != m)
			{
				// close the file before we open it with
				// the new read/write privilages
				i->file_ptr.reset();
				assert(e.file_ptr.unique());
				e.file_ptr.reset();
				e.file_ptr.reset(new file(p, m));
				e.mode = m;
			}
			pt.replace(i, e);
			return e.file_ptr;
		}
		// the file is not in our cache
		if ((int)m_files.size() >= m_size)
		{
			// the file cache is at its maximum size, close
			// the least recently used (lru) file from it
			typedef nth_index<file_set, 1>::type lru_view;
			lru_view& lt = get<1>(m_files);
			lru_view::iterator i = lt.begin();
			// the first entry in this view is the least recently used
			assert(lt.size() == 1 || (i->last_use <= boost::next(i)->last_use));
			lt.erase(i);
		}
		lru_file_entry e(boost::shared_ptr<file>(new file(p, m)));
		e.mode = m;
		e.key = st;
		e.file_path = p;
		pt.insert(e);
		return e.file_ptr;
	}
开发者ID:codeboost,项目名称:libertv,代码行数:55,代码来源:file_pool.cpp

示例2: l

	boost::shared_ptr<file> file_pool::open_file(void* st, fs::path const& p
		, file::open_mode m, error_code& ec)
	{
		TORRENT_ASSERT(st != 0);
		TORRENT_ASSERT(p.is_complete());
		TORRENT_ASSERT(m == file::in || m == (file::in | file::out));
		boost::mutex::scoped_lock l(m_mutex);
		typedef nth_index<file_set, 0>::type path_view;
		path_view& pt = get<0>(m_files);
		path_view::iterator i = pt.find(p);
		if (i != pt.end())
		{
			lru_file_entry e = *i;
			e.last_use = time_now();

			if (e.key != st && (e.mode != file::in
				|| m != file::in))
			{
				// this means that another instance of the storage
				// is using the exact same file.
#if BOOST_VERSION >= 103500
				ec = error_code(errors::file_collision, libtorrent_category);
#endif
				return boost::shared_ptr<file>();
			}

			e.key = st;
			if ((e.mode & m) != m)
			{
				// close the file before we open it with
				// the new read/write privilages
				i->file_ptr.reset();
				TORRENT_ASSERT(e.file_ptr.unique());
				e.file_ptr->close();
				if (!e.file_ptr->open(p, m, ec))
				{
					m_files.erase(i);
					return boost::shared_ptr<file>();
				}
				TORRENT_ASSERT(e.file_ptr->is_open());
				e.mode = m;
			}
			pt.replace(i, e);
			return e.file_ptr;
		}
		// the file is not in our cache
		if ((int)m_files.size() >= m_size)
		{
			// the file cache is at its maximum size, close
			// the least recently used (lru) file from it
			typedef nth_index<file_set, 1>::type lru_view;
			lru_view& lt = get<1>(m_files);
			lru_view::iterator i = lt.begin();
			// the first entry in this view is the least recently used
			TORRENT_ASSERT(lt.size() == 1 || (i->last_use <= boost::next(i)->last_use));
			lt.erase(i);
		}
		lru_file_entry e;
		e.file_ptr.reset(new (std::nothrow)file);
		if (!e.file_ptr)
		{
			ec = error_code(ENOMEM, get_posix_category());
			return e.file_ptr;
		}
		if (!e.file_ptr->open(p, m, ec))
			return boost::shared_ptr<file>();
		e.mode = m;
		e.key = st;
		e.file_path = p;
		pt.insert(e);
		TORRENT_ASSERT(e.file_ptr->is_open());
		return e.file_ptr;
	}
开发者ID:huyang819,项目名称:cdn-partner,代码行数:73,代码来源:file_pool.cpp


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