mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-18 00:40:30 -04:00
Cleanup
This commit is contained in:
parent
5cc2023a45
commit
5726ee708f
@ -197,11 +197,7 @@ void filesystem_extractor_<LoggerPolicy>::extract(filesystem_v2& fs,
|
|||||||
DWARFS_THROW(runtime_error, "getattr() failed");
|
DWARFS_THROW(runtime_error, "getattr() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto path = entry.path();
|
::archive_entry_set_pathname(ae, entry.path().c_str());
|
||||||
|
|
||||||
DWARFS_CHECK(path[0] == '/', "path expected to start with /");
|
|
||||||
|
|
||||||
::archive_entry_set_pathname(ae, path.c_str() + 1); // drop leading /
|
|
||||||
::archive_entry_copy_stat(ae, &stbuf);
|
::archive_entry_copy_stat(ae, &stbuf);
|
||||||
|
|
||||||
if (S_ISLNK(inode.mode())) {
|
if (S_ISLNK(inode.mode())) {
|
||||||
|
@ -160,8 +160,10 @@ std::string dir_entry_view::path() const {
|
|||||||
|
|
||||||
void dir_entry_view::append_path_to(std::string& s) const {
|
void dir_entry_view::append_path_to(std::string& s) const {
|
||||||
if (auto p = parent()) {
|
if (auto p = parent()) {
|
||||||
p->append_path_to(s);
|
if (!p->is_root()) {
|
||||||
s += '/';
|
p->append_path_to(s);
|
||||||
|
s += '/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!is_root()) {
|
if (!is_root()) {
|
||||||
s += name();
|
s += name();
|
||||||
|
@ -238,10 +238,6 @@ class metadata_ final : public metadata_v2::impl {
|
|||||||
return inode_view(meta_.entries()[index], inode, &meta_);
|
return inode_view(meta_.entries()[index], inode, &meta_);
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_entry_view make_dir_entry_view(uint32_t self_index) const {
|
|
||||||
return dir_entry_view::from_dir_entry_index(self_index, &meta_);
|
|
||||||
}
|
|
||||||
|
|
||||||
dir_entry_view
|
dir_entry_view
|
||||||
make_dir_entry_view(uint32_t self_index, uint32_t parent_index) const {
|
make_dir_entry_view(uint32_t self_index, uint32_t parent_index) const {
|
||||||
return dir_entry_view::from_dir_entry_index(self_index, parent_index,
|
return dir_entry_view::from_dir_entry_index(self_index, parent_index,
|
||||||
|
@ -458,7 +458,11 @@ void basic_end_to_end_test(std::string const& compressor,
|
|||||||
struct ::stat stbuf;
|
struct ::stat stbuf;
|
||||||
ASSERT_EQ(0, fs.getattr(e.inode(), &stbuf));
|
ASSERT_EQ(0, fs.getattr(e.inode(), &stbuf));
|
||||||
inodes.push_back(stbuf.st_ino);
|
inodes.push_back(stbuf.st_ino);
|
||||||
EXPECT_TRUE(entries.emplace(e.path(), stbuf).second);
|
auto path = e.path();
|
||||||
|
if (!path.empty()) {
|
||||||
|
path = "/" + path;
|
||||||
|
}
|
||||||
|
EXPECT_TRUE(entries.emplace(path, stbuf).second);
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPECT_EQ(entries.size(), dwarfs::test::statmap.size() + 2 * with_devices +
|
EXPECT_EQ(entries.size(), dwarfs::test::statmap.size() + 2 * with_devices +
|
||||||
|
@ -286,18 +286,18 @@ TEST_P(compat_filesystem, backwards_compat) {
|
|||||||
|
|
||||||
std::map<std::string, struct ::stat> ref_entries{
|
std::map<std::string, struct ::stat> ref_entries{
|
||||||
{"", make_stat(S_IFDIR | 0755, 8)},
|
{"", make_stat(S_IFDIR | 0755, 8)},
|
||||||
{"/bench.sh", make_stat(S_IFREG | 0644, 1517)},
|
{"bench.sh", make_stat(S_IFREG | 0644, 1517)},
|
||||||
{"/dev", make_stat(S_IFDIR | 0755, 0)},
|
{"dev", make_stat(S_IFDIR | 0755, 0)},
|
||||||
{"/empty", make_stat(S_IFDIR | 0755, 1)},
|
{"empty", make_stat(S_IFDIR | 0755, 1)},
|
||||||
{"/empty/alsoempty", make_stat(S_IFDIR | 0755, 0)},
|
{"empty/alsoempty", make_stat(S_IFDIR | 0755, 0)},
|
||||||
{"/foo", make_stat(S_IFDIR | 0755, 3)},
|
{"foo", make_stat(S_IFDIR | 0755, 3)},
|
||||||
{"/foo/bad", make_stat(S_IFLNK | 0777, 6)},
|
{"foo/bad", make_stat(S_IFLNK | 0777, 6)},
|
||||||
{"/foo/bar", make_stat(S_IFREG | 0644, 0)},
|
{"foo/bar", make_stat(S_IFREG | 0644, 0)},
|
||||||
{"/foo/bla.sh", make_stat(S_IFREG | 0644, 1517)},
|
{"foo/bla.sh", make_stat(S_IFREG | 0644, 1517)},
|
||||||
{"/foobar", make_stat(S_IFLNK | 0777, 7)},
|
{"foobar", make_stat(S_IFLNK | 0777, 7)},
|
||||||
{"/format.sh", make_stat(S_IFREG | 0755, 94)},
|
{"format.sh", make_stat(S_IFREG | 0755, 94)},
|
||||||
{"/perl-exec.sh", make_stat(S_IFREG | 0644, 87)},
|
{"perl-exec.sh", make_stat(S_IFREG | 0644, 87)},
|
||||||
{"/test.py", make_stat(S_IFREG | 0644, 1012)},
|
{"test.py", make_stat(S_IFREG | 0644, 1012)},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto mp : {&filesystem_v2::walk, &filesystem_v2::walk_inode_order}) {
|
for (auto mp : {&filesystem_v2::walk, &filesystem_v2::walk_inode_order}) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user