Skip to content

Commit

Permalink
multiarc/libarchive: use archive_entry_pathname_utf8 instead of archi…
Browse files Browse the repository at this point in the history
…ve_entry_pathname if possible (close ##769)
  • Loading branch information
elfmz committed Oct 6, 2020
1 parent c69d3eb commit 6c404db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion multiarc/src/formats/libarch/libarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ int WINAPI _export LIBARCH_GetArcItem(struct PluginPanelItem *Item,struct ArcIte
if (!entry)
return GETARC_EOF;

pathname = archive_entry_pathname(entry);
pathname = archive_entry_pathname_utf8(entry);
if (pathname && *pathname && strcmp(pathname, ".") != 0 && strcmp(pathname, "..") != 0) {
break;
}
Expand Down
3 changes: 2 additions & 1 deletion multiarc/src/formats/libarch/libarch_cmd_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static bool LIBARCH_CommandReadWanteds(const char *cmd, LibArchOpenRead &arc, co
break;
}

const char *pathname = archive_entry_pathname(entry);
const char *pathname = archive_entry_pathname_utf8(entry);
src_path = pathname ? pathname : "";
parts.clear();
LibArch_ParsePathToParts(parts, src_path);
Expand All @@ -58,6 +58,7 @@ static bool LIBARCH_CommandReadWanteds(const char *cmd, LibArchOpenRead &arc, co
}

if (!wanteds.empty() && !PartsMatchesAnyOfWanteds(wanteds, parts)) {
// fprintf(stderr, "Not matching: '%s'\n", pathname);
arc.SkipData();
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions multiarc/src/formats/libarch/libarch_cmd_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static bool LIBARCH_CommandRemoveOrReplace(const char *cmd, const char *arc_path
if (!entry) {
break;
}
const char *pathname = archive_entry_pathname(entry);
const char *pathname = archive_entry_pathname_utf8(entry);
if (pathname) {
parts.clear();
str = pathname;
Expand Down Expand Up @@ -268,7 +268,7 @@ static bool LIBARCH_CommandRemoveOrReplace(const char *cmd, const char *arc_path
int r = LibArchCall(archive_read_data_block, arc_src.Get(), &buf, &size, &offset);
if ((r != ARCHIVE_OK && r != ARCHIVE_WARN) || size == 0) {
throw std::runtime_error(StrPrintf("Error %d reading at 0x%llx : %s",
r, (unsigned long long)offset, archive_entry_pathname(entry)));
r, (unsigned long long)offset, archive_entry_pathname_utf8(entry)));
}
if (!arc_dst.WriteData(buf, size)) {
throw std::runtime_error("write data failed");
Expand Down
3 changes: 3 additions & 0 deletions multiarc/src/formats/libarch/libarch_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ struct LibArchOpenWrite
LibArchOpenWrite(const LibArchOpenWrite&) = delete;
};

#if (ARCHIVE_VERSION_NUMBER < 3002000)
# define archive_entry_pathname_utf8 archive_entry_pathname
#endif

0 comments on commit 6c404db

Please sign in to comment.