-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboostfs.cpp
More file actions
44 lines (40 loc) · 1.21 KB
/
boostfs.cpp
File metadata and controls
44 lines (40 loc) · 1.21 KB
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
#include <boost/filesystem.hpp>
#include <boost/range/istream_range.hpp>
#include <iostream>
namespace fs = boost::filesystem;
int
main(int argc, char** argv)
{
if (argc < 1)
{
std::cout << "need path" << std::endl;
return 1;
}
for (int i = 1; i < argc; i++)
{
fs::path p = argv[i];
auto rstr = p.generic_string();
auto rlen = rstr.length();
auto dir = boost::make_iterator_range(fs::recursive_directory_iterator(p), {});
for (const auto& e : dir)
{
if (!fs::is_directory(e))
{
auto path = e.path();
auto pstr = path.generic_string();
auto len = pstr[rlen] == '/' ? rlen + 1 : rlen;
auto rels = pstr.substr(len);
std::cout << path << ":\n"
<< "\tREL:\t" << path.relative_path() << "\n"
<< "\tREL2:\t" << rels << "\n"
<< "\tFILE:\t" << path.filename() << "\n"
<< "\tROOT:\t" << path.root_path() << "\n"
<< "\tROOT:\t" << path.root_directory() << "\n"
<< "\tPAR:\t" << path.parent_path() << "\n"
<< "\tRN:\t" << path.root_name() << "\n"
<< std::endl;
}
}
}
return 0;
}