#include <boost/filesystem/fstream.hpp>
void TestFileSystem()
{
namespace fs = boost::filesystem;
std::cout << fs::current_path().string() << std::endl;
if (fs::is_directory(fs::path("boost_directory")))
{
fs::recursive_directory_iterator end;
fs::recursive_directory_iterator pos(fs::path("boost_directory"));
while (pos != end )
{
fs::path file_path(pos->path());
std::cout << file_path.string() << std::endl;
if (fs::is_directory(*pos))
{
//fs::remove_all(*pos++);
}
else if (fs::is_regular_file(*pos))
{
//fs::remove(*pos++);
}
++pos;
}
//fs::path unique_path = fs::unique_path();
fs::path unique_path = fs::unique_path(fs::path("sniper-%%%%-%%%%-%%%%-%%%%"));
std::cout << unique_path.string() <<"-----"<<fs::system_complete(unique_path).string()<< std::endl;
fs::create_directories(unique_path);
//fs::remove_all(fs::path("boost_directory"));//删除全部子文件、子文件夹以及自身
}
else
{
std::cout << "boost_directory 不是一个目录" << std::endl;
}
}