本文整理汇总了C++中boost::filesystem::path::directory_string方法的典型用法代码示例。如果您正苦于以下问题:C++ path::directory_string方法的具体用法?C++ path::directory_string怎么用?C++ path::directory_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::directory_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_all
inline
void remove_all(const boost::filesystem::path& path)
{
if (__is_directory(path)) {
std::vector<boost::filesystem::path> paths;
#if BOOST_FILESYSTEM_VERSION == 2
DIR* dirp = (path.empty() ? ::opendir(".") : ::opendir(path.directory_string().c_str()));
#else
DIR* dirp = (path.empty() ? ::opendir(".") : ::opendir(path.string().c_str()));
#endif
if (dirp) {
struct dirent* dp;
do {
errno = 0;
if ((dp = readdir(dirp)) != 0) {
const std::string path_leaf(dp->d_name);
if (path_leaf != "." && path_leaf != "..")
paths.push_back(path / path_leaf);
}
} while (dp);
::closedir(dirp);
}
std::for_each(paths.begin(), paths.end(), utils::filesystem::remove_all);
}
#if BOOST_FILESYSTEM_VERSION == 2
if (__exists(path))
::remove(path.file_string().c_str());
#else
if (__exists(path))
::remove(path.string().c_str());
#endif
errno = 0;
}
示例2: display
void display( const bfs::path & p)
{
long int fc=0,dc=0,ec=0,oc=0;
if( bfs::is_directory(p))
{
cout<<"In Directory:"<< p.directory_string()<<"\n\n";
bfs::directory_iterator i(p), e;
for(i;i!=e;++i)
{
if(bfs::is_directory( i->status()))
{
dc++;
display(*i);
//cout<< i->path().filename()<<"[directory]\n";
}
else if(bfs::is_regular_file(i->status()))
{
fc++;
cout<<i->path().filename()<<"[file]\n";
}
else
{
oc++;
cout<<i->path().filename()<<"[others]\n";
}
}
cout<<"File Count:"<<fc<<"\n";
cout<<"Directory COunt"<<dc<<"\n";
cout<<"Others Count"<<oc<<"\n";
}
else
{
cout<<"File Found"<<p.file_string()<<"\n\n";
}
}