本文整理汇总了C++中Printer::cerr方法的典型用法代码示例。如果您正苦于以下问题:C++ Printer::cerr方法的具体用法?C++ Printer::cerr怎么用?C++ Printer::cerr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Printer
的用法示例。
在下文中一共展示了Printer::cerr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: worker
// worker requests items from the queue which are either file or
// directory paths. If item is
// 1) a filepath: computes and prints the hash of the file
// 2) a directory path: adds contained files and directories contained to
// the queue
void worker(StringQueue& fileQueue, const Printer& printer, RefData& rd,
Stats& stats, CmdLineOpts& opts) {
// if we receive a non-empty refMap we compare against it
bool compare = false;
if (!rd.refMap.empty()) {
compare = true;
}
while (!fileQueue.done()) {
auto path = fileQueue.try_and_wait();
if (path.empty()) {
break;
}
// check if path is a directory or a file
struct stat info;
if (lstat(path.c_str(), &info) < 0) {
printer.cerr("lstat failed on " + path);
continue;
}
if (S_ISREG(info.st_mode)) {
std::string hash = hasher(opts.hashMethod, path);
if (opts.collectStats) {
stats.add(info.st_size);
}
if (compare) {
compare_to_reference(path, hash, printer, rd);
} else {
printer.cout(opts.hashMethod + " , " + path + " , " + hash);
}
} else if (S_ISDIR(info.st_mode)) {
add_directory(fileQueue, path, printer);
}
}
}