1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <boost/filesystem.hpp>
#include <string>
#include <iostream>
template<class stringT>
struct CvsDir;
template<> struct CvsDir<std::string>
{
static const char* name = "CVS";
};
template<> struct CvsDir<std::wstring>
{
static const wchar_t* name = L"CVS";
};
template<class pathT>
bool CopyWithoutCVS(pathT src, pathT dst)
{
namespace fs = boost::filesystem;
try
{
if(!fs::exists(src))
return false;
if(fs::is_directory(src))
{
//directory mode
// std::cout << src.leaf() << "is a directory" << std::endl;
if(equivalent(src.leaf(), CvsDir<pathT::string_type>::name))
return false;
fs::directory_iterator dirEnd;
for(fs::directory_iterator srcIter(src); srcIter != dirEnd; srcIter++)
{
bool bRet = CopyWithoutCVS<pathT>(*srcIter, dst);
}
}
else if(fs::is_regular(src))
{
//file mode
// std::cout << src.leaf() << "is a file" << std::endl;
}
return true;
}
catch(fs::basic_filesystem_error<pathT>& e)
{
// std::cerr << "Cannot read path." << e.what() << std::endl;
return false;
}
} |
Partager