网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

boost中如何使用filesystem库

本篇文章给大家分享的是有关boost中如何使用filesystem库,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

目前创新互联公司已为1000+的企业提供了网站建设、域名、雅安服务器托管、网站改版维护、企业网站设计、大渡口网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

ma_dir_op.h:

////////////////////////////////////////////////////////////////
//
//Descript: directory operation class
//  Author: guowenyan
//    Date: 2013.06.13
//
////////////////////////////////////////////////////////////////
#pragma once
#include 
#include 

class CMaDirOperation
{
public:
	static CMaDirOperation *get_instance();

public:
	bool traverse_path(std::vector &vec_file_name, const std::string &path, const std::string &file_type = "") const;

	bool is_file_exist(const std::string &path, const std::string &file_name) const;
	bool is_file_exist(const std::string &file_name) const;

	bool delete_file(const std::string &path, const std::string &file_name) const;
	bool delete_file(const std::string &file_name) const;

	bool delete_directory(const std::string &path_name) const;

	void copy_file(const std::string &s_file_name, const std::string &d_file_name) const;
	void copy_directory(const std::string &s_path_name, const std::string &d_path_name) const;

	bool chang_file_type(const std::string &file_name, const std::string &s_file_type, const std::string &d_file_type, std::string &changed_file_name) const;

private:
	CMaDirOperation() { };
	~CMaDirOperation() { };
	bool is_file_type(const std::string &file_name, const std::string &file_type) const;

private:
	static CMaDirOperation* m_p_instance;
};

ma_dir_op.cpp:

////////////////////////////////////////////////////////////////
//
//Descript: directory operation class
//  Author: guowenyan
//    Date: 2013.06.13
//
////////////////////////////////////////////////////////////////
#include "ma_dir_op.h"

#include 
#include 

using namespace std;

namespace fs = boost::filesystem;



CMaDirOperation* CMaDirOperation::m_p_instance = NULL;

CMaDirOperation* CMaDirOperation::get_instance()
{
	if(NULL == m_p_instance)
		m_p_instance = new CMaDirOperation();
	return m_p_instance;
}

bool CMaDirOperation::traverse_path(vector &vec_file_name, const string &path, const string &file_type/* = ""*/) const
{
	if(!fs::exists(path))
	{
		cout<<"the path "< vec_file_name;
	if(!traverse_path(vec_file_name, path_name))
		return false;

	vector::iterator ite = vec_file_name.begin();
	for(; ite != vec_file_name.end(); ite++)
	{
		delete_file(path_name + (*ite));
	}

	return true;
}

void CMaDirOperation::copy_file(const string &s_file_name, const string &d_file_name) const
{
	fs::path s_path(s_file_name);
	fs::path d_path(d_file_name);

	fs::copy_file(s_path, d_path, fs::copy_option::fail_if_exists);
}

void CMaDirOperation::copy_directory(const std::string &s_path_name, const std::string &d_path_name) const
{
	vector vec_file_name;
	if(traverse_path(vec_file_name, s_path_name))
	{
		vector::iterator ite = vec_file_name.begin();
		for(; ite != vec_file_name.end(); ite++)
		{
			copy_file(s_path_name + (*ite), d_path_name + (*ite));
		}
	}
}

bool CMaDirOperation::chang_file_type(const string &file_name, const std::string &s_file_type, const std::string &d_file_type, std::string &changed_file_name) const
{
	if(!is_file_type(file_name, s_file_type))
	{
		cout<<"File name "<

以上就是boost中如何使用filesystem库,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。


本文题目:boost中如何使用filesystem库
网页网址:http://bjjierui.cn/article/gdggop.html

其他资讯