tool to count the objects in a directory tree
More...
|
static options::single< bool > | ignoreAccess ('i', "ignoreAccess", "ignore subdirs we may not access") |
|
static options::single< bool > | quiet ('q', "quiet", "be quiet, no prefix to output lines") |
|
static options::single< bool > | reportUnknowns ('U',"reportUnknowns", "print a list of items with type DT_UNKNOWN") |
|
static options::single< unsigned > | nThreads ('n', "nThreads", "number of threads", 0) |
|
static std::forward_list< std::string > | unknownList |
|
static std::mutex | unknownListMutex |
|
static unsigned int | runnerType::nWorkers |
|
static std::mutex | runnerType::listMutex |
|
static std::condition_variable | runnerType::cv |
|
static std::atomic< unsigned int > | runnerType::nActiveWorkers |
|
tool to count the objects in a directory tree
◆ dirQueueType
◆ handleDir()
void handleDir |
( |
const std::string & |
path, |
|
|
counterType & |
counter |
|
) |
| |
Definition at line 259 of file dirCount.cpp.
262 auto result = opendir(path.c_str());
264 if (result ==
nullptr) {
266 counter.
count(counterType::specials::denied);
268 }
else if (errno == ENOENT) {
269 counter.
count(counterType::specials::noent);
271 }
else if (errno == ENOTDIR) {
272 counter.
count(counterType::specials::notdir);
278 std::forward_list<std::string> subdirs;
281 while (
auto entry = readdir(dir)) {
283 if (entry->d_name[entry->d_name[0] !=
'.' ? 0 : entry->d_name[1] !=
'.' ? 1 : 2] ==
'\0') {
287 counter.
count(entry->d_type);
288 if (entry->d_type == DT_DIR) {
289 subdirs.emplace_front(entry->d_name);
291 std::string item(path);
293 item += entry->d_name;
298 for (
const auto& subdir : subdirs) {
References throwcall::badval(), counterType::count(), ignoreAccess, reportUnknowns, timer::instanceUnscoped::restart(), timer::instanceUnscoped::stop(), and unknownList.
Referenced by main().
◆ main()
int main |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
Definition at line 304 of file dirCount.cpp.
307 "paths to consider");
310 parser.fParse(argc, argv);
314 for (
auto path : paths) {
319 nThreads = sysconf(_SC_NPROCESSORS_ONLN);
322 for (
const auto& path : paths) {
325 for (
unsigned int i = 0; i < paths.size(); i++) {
335 std::cout <<
"List of items of type DT_UNKNOWN:\n";
337 std::cout << item <<
"\n";
References MyWaitQueues::simple< T >::emplace(), runnerType::finish(), handleDir(), counterType::init(), runnerType::newWorker(), nThreads, timer::anchor::print(), counterType::print(), reportUnknowns, and unknownList.
◆ cv
std::condition_variable runnerType::cv |
|
staticprivate |
◆ ignoreAccess
options::single<bool> ignoreAccess( 'i', "ignoreAccess", "ignore subdirs we may not access") |
|
static |
◆ listMutex
std::mutex runnerType::listMutex |
|
staticprivate |
◆ nActiveWorkers
std::atomic< unsigned int > runnerType::nActiveWorkers |
|
staticprivate |
◆ nThreads
options::single<unsigned> nThreads( 'n', "nThreads", "number of threads", 0) |
|
static |
◆ nWorkers
unsigned int runnerType::nWorkers |
|
static |
◆ quiet
options::single<bool> quiet( 'q', "quiet", "be quiet, no prefix to output lines") |
|
static |
◆ reportUnknowns
options::single<bool> reportUnknowns( 'U',"reportUnknowns", "print a list of items with type DT_UNKNOWN") |
|
static |
◆ unknownList
std::forward_list<std::string> unknownList |
|
static |
◆ unknownListMutex
std::mutex unknownListMutex |
|
static |
T badval(T call, t badvalue, const Args &... args)
template function to wrap system calls that return a special bad value on failure