Create long file path before passing to mkdirp (#238)

* Create long file path before passing to mkdirp

* Updated other calls to mkdirp

* Updated mkdirp method to handle both long path and without long path strings
This commit is contained in:
jyvenugo 2019-10-15 12:36:29 -07:00 коммит произвёл GitHub
Родитель add4a30436
Коммит 3ffa01eeb9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -19,8 +19,8 @@ const PCWSTR Extractor::HandlerName = L"Extractor";
HRESULT Extractor::GetOutputStream(LPCWSTR path, LPCWSTR fileName, IStream** stream)
{
std::wstring fullFileName = path + std::wstring(L"\\") + fileName;
RETURN_IF_FAILED(HRESULT_FROM_WIN32(mkdirp(fullFileName)));
std::wstring longFileName = std::wstring(L"\\\\?\\") + fullFileName;
RETURN_IF_FAILED(HRESULT_FROM_WIN32(mkdirp(longFileName)));
RETURN_IF_FAILED(CreateStreamOnFileUTF16(longFileName.c_str(), false, stream));
return S_OK;
}

Просмотреть файл

@ -37,7 +37,8 @@ HRESULT PopulatePackageInfo::GetPackageInfoFromManifest(const std::wstring & dir
// On non-Win32 platforms CoCreateAppxFactory will return 0x80070032 (e.g. HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED))
// So on all platforms, it's always safe to call CoCreateAppxFactoryWithHeap, just be sure to bring your own heap!
ComPtr<IStream> inputStream;
RETURN_IF_FAILED(CreateStreamOnFileUTF16(manifestPath.c_str(), /*forRead*/ true, &inputStream));
std::wstring longManifestPath = std::wstring(L"\\\\?\\") + manifestPath;
RETURN_IF_FAILED(CreateStreamOnFileUTF16(longManifestPath.c_str(), /*forRead*/ true, &inputStream));
// Create a new package reader using the factory.
ComPtr<IAppxFactory> appxFactory;

Просмотреть файл

@ -246,7 +246,16 @@ namespace MsixCoreLib
int mkdirp(std::wstring& utf16Path)
{
replace(utf16Path, L'/', L'\\');
for (std::size_t i = 3; i < utf16Path.size(); i++) // 3 skips past c:
std::size_t startIndex = 0;
if (utf16Path.find(L"\\\\?\\") != std::wstring::npos)
{
startIndex = 7; // 7 skips past \\?\ for handling long file path and c:
}
else
{
startIndex = 3; // 3 skips past c:
}
for (std::size_t i = startIndex; i < utf16Path.size(); i++)
{
if (utf16Path[i] == L'\0')
{