16 return std::unique_ptr<base::reader>(
new readerDcap(aPath,
26 reader(inititalStat) {
28 fd = dc_open(
path.c_str(), O_RDONLY);
31 || (errno == ENOTDIR && !S_ISDIR(readInitialStat.mode))) {
43 if (dc_close(fd) != 0) {
45 path,
"close during unwind ",
46 dc_strerror(dc_errno));
56 b.
clear(totalBytesRead);
57 bool lastblock =
false;
62 -1,
"read failed on ", path);
64 if (bytes_read == 0) {
66 if (totalBytesRead < readInitialStat.size) {
68 std::to_string(readInitialStat.size) +
70 std::to_string(totalBytesRead) +
75 totalBytesRead += bytes_read;
76 if (totalBytesRead > readInitialStat.size) {
78 std::to_string(readInitialStat.size) +
80 std::to_string(totalBytesRead) +
95 genericStat readFinalStat(readFinalStatBuf, std::chrono::seconds(1));
96 if (readFinalStat.
size != readInitialStat.size) {
98 std::to_string(readInitialStat.size) +
100 std::to_string(readFinalStat.
size) +
101 ") during reading on " + path);
106 std::to_string(std::chrono::duration_cast<std::chrono::duration<double>>(readFinalStat.
getMtime() - readInitialStat.getMtime()).count()) +
107 "s different mtime) during reading");
118 if (dc_closedir(dir) != 0) {
120 path,
"close directory during unwind ",
121 dc_strerror(dc_errno));
129 while (
auto entry = dc_readdir(dir)) {
130 if (entry->d_name[entry->d_name[0] !=
'.' ? 0 : entry->d_name[1] !=
'.' ? 1 : 2] ==
'\0') {
135 auto result = dc_stat(entrypath.c_str(), &statbuf);
136 if (result != 0 && errno == ENOENT && ignoreMissing) {
140 auto genStat = std::unique_ptr<const genericStat>(
new genericStat(statbuf, std::chrono::seconds(1)));
141 return std::unique_ptr<Entry>(
new Entry(entry->d_name, genStat));