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


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

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


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

示例1: extract_file

void Container::extract_file(const path& relative_path)
{
	send_callback(INFORMATION, EXTRACT_FILE, relative_path.raw_std_str());
	if (file_exists(relative_path.str()))
	{
		std::string location(relative_path.str());
		std::string filename(relative_path.get_filename());
		std::string folder(relative_path.get_folderpath_unsecure());

		container_handle::file_node fnode = handle_.get_filenode(relative_path);

		if (fnode.p == folder)
		{
			switch (algo_)
			{
			case AES:
				helper_extract_file<CryptoPP::AES>(fnode, (*volume_).drive_letter);
				break;
			case SERPENT:
				helper_extract_file<CryptoPP::Serpent>(fnode, (*volume_).drive_letter);
				break;
			case TWOFISH:
				helper_extract_file<CryptoPP::Twofish>(fnode, (*volume_).drive_letter);
				break;
			}
		}

	}
	//THROW
}
开发者ID:KaiSta,项目名称:scrates,代码行数:30,代码来源:Container.cpp

示例2: HashFilter

Container::Container(const path& location, const std::string& pw, VirtualDisk_Impl::volume_handle* volume, encryption_algorithm algo) : volume_(volume), 
passphrase_(pw.begin(), pw.end()), seed_(32), is_syncing(false), container_open_(false), has_callback_(false)
{
	using namespace CryptoPP;
	SHA256 shafunc;
	StringSource(pw.data(), true, new HashFilter(shafunc, new StringSink(pw_)));
	
	container_name_ = location.get_filename();
	container_name_.erase(container_name_.find_first_of('.'), container_name_.size());
	path_ = location;
	location.create_folderpath();
	algo_ = algo;
	if (enhanced_passphrase_.size())
	{
		std::vector<byte> tmp(std::begin(pw), std::end(pw));
		tmp.insert(std::end(tmp), std::begin(enhanced_passphrase_), std::end(enhanced_passphrase_));
		std::swap(tmp, enhanced_passphrase_);
	}
	else
	{
		for (byte b : pw)
		{
			enhanced_passphrase_.push_back(b);
		}
	}
}
开发者ID:KaiSta,项目名称:scrates,代码行数:26,代码来源:Container.cpp

示例3: init

void Container::init(const path& location, const std::string& pw, encryption_algorithm algo)
{
	using namespace CryptoPP;
	send_callback(VERBOSE, INIT_CONTAINER, location.std_str());
	SHA256 shafunc;
	StringSource(pw.data(), true, new HashFilter(shafunc, new StringSink(pw_)));
	
	if (enhanced_passphrase_.size())
	{
		std::vector<byte> tmp(std::begin(pw), std::end(pw));
		tmp.insert(std::end(tmp), std::begin(enhanced_passphrase_), std::end(enhanced_passphrase_));
		std::swap(tmp, enhanced_passphrase_);
	}
	else
	{
		for (byte b : pw)
		{
			enhanced_passphrase_.push_back(b);
		}
	}
	container_name_ = location.get_filename();
	container_name_.erase(container_name_.find_first_of('.'), container_name_.size());
	path_ = location; //fehler filename muss noch raus aus dem string
	location.create_folderpath();
	algo_ = algo;
}
开发者ID:KaiSta,项目名称:scrates,代码行数:26,代码来源:Container.cpp

示例4: add_file

void Container::add_file(const path& src, const std::string& rootfolder)
{
	if (!validate())
	{
		if (has_callback_)
			send_callback(CONFLICT, MISSING_ENC_FILES);
		else
			throw(std::logic_error("severe: synchronization with cloud incomplete!"));
		return;
	}
	std::string location = src.str();
	std::string file_name = src.get_filename();

	using namespace CryptoPP;
	/*std::string crc;
	if (!secure_crc(location, crc))
	{
		return;
	}*/
  std::string hash;
  if (!secure_hash(location, hash))
  {
    return;
  }

	auto folderstart = location.find(rootfolder);
	auto folderend = location.find(src.get_filename());
	path relativepath(std::string(location.begin() + folderstart, location.begin() + (folderend - 1)));
	path tmp = relativepath.append_filename(file_name);

	container_handle::file_node fnode = handle_.get_filenode(tmp);
	if (fnode.p == relativepath)
	{
		update_file(src.get_filename(), relativepath, src);
		return;
	}

	if (FileSystem::file_exists(location))
	{	
		send_callback(INFORMATION, ADD_FILE, src.std_str());
		auto size = FileSystem::file_size(location);
		if (size >= 0)
		{
			path store_path;
			if (!handle_.where_to_store(size, store_path)) { return; }
			CloudManager& manager = CloudManager::instance();
			std::string location_name = manager.get_location_name(store_path.raw_str());
			container_handle::file_node file;
			file.filename = src.get_filename();
			file.size = size;
			file.p = relativepath.std_str();

			//file.crc = crc;
      file.hash = hash;

			std::string key;
			std::string iv;
			std::string hashname;
			bool ret = false;

			//file verschluesseln hier
			switch (algo_)
			{
			case AES:
				ret = helper_add_file<CryptoPP::AES>(src, store_path, iv, hashname);
				break;
			case SERPENT:
				ret = helper_add_file<CryptoPP::Serpent>(src, store_path, iv, hashname);
				break;
			case TWOFISH:
				ret = helper_add_file<CryptoPP::Twofish>(src, store_path, iv, hashname);
				break;
			default:
				return;
			}

			if (!ret)
			{
				handle_.update_memusage_location(location_name, -size);
				return;
			}

			container_handle::block_node block_node;
			block_node.id = 1;
			block_node.location = location_name;
      block_node.hash = hash;
			//block_node.crc = crc;
			block_node.filename = hashname;
			file.blocks.push_back(block_node);
			handle_.add_file_node(file);

			save();
		}

	}
#ifdef TDEBUG
	handle_.dump(std::string("C:\\Users\\Kai\\Desktop\\new_test.xml"));
#endif
}
开发者ID:KaiSta,项目名称:scrates,代码行数:99,代码来源:Container.cpp


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