diff -ru a/CPP/7zip/Archive/GptHandler.cpp b/CPP/7zip/Archive/GptHandler.cpp --- a/CPP/7zip/Archive/GptHandler.cpp 2026-10-09 18:08:33.721749900 -0400 +++ b/CPP/7zip/Archive/GptHandler.cpp 2026-10-09 18:08:55.074039300 -0400 @@ -2,6 +2,7 @@ #include "StdAfx.h" +#include #include "../../../C/7zCrc.h" #include "../../../C/CpuArch.h" @@ -348,6 +349,19 @@ IMP_IInArchive_Props IMP_IInArchive_ArcProps +// johnmcm.com: with several partitions, 7-Zip opens none of them by itself. +// JOHNMCM_PARTITION= names the one to open, so a page can list a +// partition's files in place instead of copying the partition out first. +static int Johnmcm_ChosenPartition(unsigned count) +{ + const char *s = getenv("JOHNMCM_PARTITION"); + if (!s || !*s) + return -1; + char *end; + const unsigned long i = strtoul(s, &end, 10); + return (*end == 0 && i < count) ? (int)i : -1; +} + Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)) { COM_TRY_BEGIN @@ -358,6 +372,12 @@ { if (_items.Size() == 1) prop = (UInt32)0; + else + { + const int chosen = Johnmcm_ChosenPartition(_items.Size()); + if (chosen >= 0) + prop = (UInt32)chosen; + } break; } case kpidPhySize: prop = _totalSize; break; diff -ru a/CPP/7zip/Archive/MbrHandler.cpp b/CPP/7zip/Archive/MbrHandler.cpp --- a/CPP/7zip/Archive/MbrHandler.cpp 2026-10-09 18:08:33.729514400 -0400 +++ b/CPP/7zip/Archive/MbrHandler.cpp 2026-10-09 18:08:55.075038500 -0400 @@ -2,6 +2,7 @@ #include "StdAfx.h" +#include // #define SHOW_DEBUG_INFO #ifdef SHOW_DEBUG_INFO @@ -529,6 +530,19 @@ IMP_IInArchive_ArcProps +// johnmcm.com: with several partitions, 7-Zip opens none of them by itself. +// JOHNMCM_PARTITION= names the one to open, so a page can list a +// partition's files in place instead of copying the partition out first. +static int Johnmcm_ChosenPartition(unsigned count) +{ + const char *s = getenv("JOHNMCM_PARTITION"); + if (!s || !*s) + return -1; + char *end; + const unsigned long i = strtoul(s, &end, 10); + return (*end == 0 && i < count) ? (int)i : -1; +} + Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)) { NCOM::CPropVariant prop; @@ -547,6 +561,12 @@ } mainIndex = (int)i; } + if (mainIndex < 0) + { + const int chosen = Johnmcm_ChosenPartition(_items.Size()); + if (chosen >= 0 && _items[(unsigned)chosen].IsReal) + mainIndex = chosen; + } if (mainIndex >= 0) prop = (UInt32)(Int32)mainIndex; break;