Skip to content

Commit 1005b78

Browse files
authored
Handle 7zip extraction separately (#1548)
1 parent b4b372c commit 1005b78

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

include/vcpkg/archives.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ namespace vcpkg
2121
SevenZip,
2222
Nupkg,
2323
Msi,
24-
Exe
24+
Exe,
25+
SelfExtracting7z
2526
};
2627

2728
// Extract `archive` to `to_path` using `tar_tool`.

src/vcpkg-test/archives.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ TEST_CASE ("Testing guess_extraction_type", "[z-extract]")
1515
REQUIRE(guess_extraction_type(Path("/path/to/archive.xz")) == ExtractionType::Tar);
1616
REQUIRE(guess_extraction_type(Path("/path/to/archive.exe")) == ExtractionType::Exe);
1717
REQUIRE(guess_extraction_type(Path("/path/to/archive.unknown")) == ExtractionType::Unknown);
18+
REQUIRE(guess_extraction_type(Path("/path/to/archive.7z.exe")) == ExtractionType::SelfExtracting7z);
1819
}

src/vcpkg/archives.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,16 @@ namespace vcpkg
156156
}
157157
else if (Strings::case_insensitive_ascii_equals(ext, ".exe"))
158158
{
159-
return ExtractionType::Exe;
159+
// Special case to differentiate between self-extracting 7z archives and other exe files
160+
const auto stem = archive.stem();
161+
if (Strings::case_insensitive_ascii_equals(Path(stem).extension(), ".7z"))
162+
{
163+
return ExtractionType::SelfExtracting7z;
164+
}
165+
else
166+
{
167+
return ExtractionType::Exe;
168+
}
160169
}
161170
else
162171
{
@@ -188,6 +197,9 @@ namespace vcpkg
188197
extract_tar(tools.get_tool_path(Tools::TAR, status_sink), archive, to_path);
189198
break;
190199
case ExtractionType::Exe:
200+
win32_extract_with_seven_zip(tools.get_tool_path(Tools::SEVEN_ZIP, status_sink), archive, to_path);
201+
break;
202+
case ExtractionType::SelfExtracting7z:
191203
const Path filename = archive.filename();
192204
const Path stem = filename.stem();
193205
const Path to_archive = Path(archive.parent_path()) / stem;

vcpkg-init/vcpkg-scripts-sha.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d033613d9021107e4a7b52c5fac1f87ae8a6fcc6
1+
0c4cf19224a049cf82f4521e29e39f7bd680440c

0 commit comments

Comments
 (0)