Exemple #1
0
	void file_storage::update_path_index(internal_file_entry& e)
	{
		std::string parent = parent_path(e.filename());
		if (parent.empty())
		{
			e.path_index = -1;
		}
		else
		{
			// do we already have this path in the path list?
			std::vector<std::string>::reverse_iterator p
				= std::find(m_paths.rbegin(), m_paths.rend(), parent);

			if (p == m_paths.rend())
			{
				// no, we don't. add it
				e.path_index = m_paths.size();
				m_paths.push_back(parent);
			}
			else
			{
				// yes we do. use it
				e.path_index = p.base() - m_paths.begin() - 1;
			}
			e.set_name(filename(e.filename()).c_str());
		}
	}
Exemple #2
0
	internal_file_entry::internal_file_entry(internal_file_entry const& fe)
		: name(0)
		, offset(fe.offset)
		, symlink_index(fe.symlink_index)
		, size(fe.size)
		, name_len(fe.name_len)
		, pad_file(fe.pad_file)
		, hidden_attribute(fe.hidden_attribute)
		, executable_attribute(fe.executable_attribute)
		, symlink_attribute(fe.symlink_attribute)
		, path_index(fe.path_index)
	{
		set_name(fe.filename().c_str());
	}
Exemple #3
0
	std::string file_storage::file_path(internal_file_entry const& fe) const
	{
		TORRENT_ASSERT(fe.path_index >= -1 && fe.path_index < int(m_paths.size()));
		if (fe.path_index == -1) return fe.filename();
		return combine_path(m_paths[fe.path_index], fe.filename());
	}
	std::string file_storage::file_name(internal_file_entry const& fe) const
	{
		return fe.filename();
	}