// Callback for use with nftw(3) to assist with clearing files and sub-directories. // This method removes files and directories below the top-level directory passed to nftw(). staticint NftwCleanUpCallback(constchar* fpath,
[[maybe_unused]] conststruct stat* sb, int typeflag, struct FTW* ftwbuf) { switch (typeflag) { case FTW_F: return unlink(fpath); case FTW_DP: return (ftwbuf->level == 0) ? 0 : rmdir(fpath); default: return -1;
}
}
static constexpr int kMaxDescriptors = 4; // Limit the need for nftw() to re-open descriptors. if (nftw(dir_path.c_str(), NftwCleanUpCallback, kMaxDescriptors, FTW_DEPTH | FTW_MOUNT) != 0) {
LOG(ERROR) << "Failed to clean-up '" << dir_path << "'"; returnfalse;
}
if (rmdir(dir_path.c_str()) != 0) { // It's possible that we are not able to remove the directory itself. For example, when // odrefresh is running in CompOS, the staging dir is prepared beforehand passed to the VM as an // FD. In this case, just log and ignore the error. It's okay to keep the directory.
LOG(WARNING) << "Failed to delete '" << dir_path << "'";
}
uint64_t file_bytes = 0;
std::queue<std::string> unvisited;
unvisited.push(path); while (!unvisited.empty()) {
std::string current = unvisited.front();
unvisited.pop();
std::unique_ptr<DIR, int (*)(DIR*)> dir(opendir(current.c_str()), closedir); if (!dir) { continue;
} for (auto entity = readdir(dir.get()); entity != nullptr; entity = readdir(dir.get())) {
std::string_view name{entity->d_name}; if (name == kCurrentDirectory || name == kParentDirectory) { continue;
}
std::string entity_name = current + "/" + entity->d_name; if (entity->d_type == DT_DIR) {
unvisited.push(entity_name.c_str());
} elseif (entity->d_type == DT_REG) { struct stat sb; if (stat(entity_name.c_str(), &sb) != 0) {
PLOG(ERROR) << "Failed to stat() file " << entity_name; continue;
}
file_bytes += sb.st_blocks * kBytesPerBlock;
}
}
}
*bytes = file_bytes; returntrue;
}
} // namespace odrefresh
} // namespace art
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.9Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.