Skip to content

Commit 10ed490

Browse files
committed
Support PAX headers.
Fix #68.
1 parent a84126e commit 10ed490

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

LxRunOffline/fs.cpp

+22-3
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,25 @@ void archive_reader::run(fs_writer &writer) {
454454
archive_entry *pe;
455455
while (check_archive(pa.get(), archive_read_next_header(pa.get(), &pe))) {
456456
print_progress((double)archive_filter_bytes(pa.get(), -1) / as);
457-
auto p = from_utf8(archive_entry_pathname(pe));
457+
wstr p;
458+
auto up = archive_entry_pathname(pe);
459+
if (up) p = from_utf8(up);
460+
else {
461+
auto wp = archive_entry_pathname_w(pe);
462+
if (wp) p = wp;
463+
else throw error_other(err_convert_encoding, {});
464+
}
458465
if (!normalize_linux_path(p, rp)) continue;
466+
wstr tp;
467+
bool hl = true;
459468
auto utp = archive_entry_hardlink(pe);
460-
if (utp) {
461-
auto tp = from_utf8(utp);
469+
if (utp) tp = from_utf8(utp);
470+
else {
471+
auto wtp = archive_entry_hardlink_w(pe);
472+
if (wtp) tp = wtp;
473+
else hl = false;
474+
}
475+
if (hl) {
462476
if (normalize_linux_path(tp, rp)) {
463477
writer.write_hard_link(p, tp);
464478
}
@@ -491,6 +505,11 @@ void archive_reader::run(fs_writer &writer) {
491505
writer.write_file_data(nullptr, 0);
492506
} else if (type == AE_IFLNK) {
493507
auto tp = archive_entry_symlink(pe);
508+
std::unique_ptr<char[]> ptp = nullptr;
509+
if (!tp) {
510+
ptp = to_utf8(archive_entry_symlink_w(pe));
511+
tp = ptp.get();
512+
}
494513
writer.write_symlink(p, attr, tp);
495514
} else { // AE_IFDIR
496515
writer.write_directory(p, attr);

0 commit comments

Comments
 (0)