Cleanup cpio codebase

This commit is contained in:
topjohnwu
2023-06-03 00:31:20 -07:00
parent feb44f875e
commit 57afae3425
8 changed files with 74 additions and 57 deletions

View File

@@ -463,11 +463,21 @@ bool byte_data::contains(string_view pattern, bool log) const {
return false;
}
bool byte_data::equals(const byte_data &o) const {
return sz == o.sz && memcmp(buf, o.buf, sz) == 0;
}
void byte_data::swap(byte_data &o) {
std::swap(buf, o.buf);
std::swap(sz, o.sz);
}
heap_data byte_data::clone() const {
heap_data copy(sz);
memcpy(copy.buf, buf, sz);
return copy;
}
mmap_data::mmap_data(const char *name, bool rw) {
int fd = xopen(name, (rw ? O_RDWR : O_RDONLY) | O_CLOEXEC);
if (fd < 0)