x2t - fix bug #46662

This commit is contained in:
ElenaSubbotina
2020-09-21 08:28:22 +03:00
parent 7c459a1235
commit 36da9596c3

View File

@ -634,6 +634,7 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback*
wstring szText;
zipFile zf = zipOpenHelp(outputFile);
if (!zf) return -1;
unsigned int filesCount = get_files_count( dir );
unsigned int currentFileIndex = 0;
@ -760,36 +761,38 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback*
if(oFile.ReadFile(pData, oFile.GetFileSize(), dwSizeRead))
{
zipFile zf = zipOpenHelp(outputFile);
if (zf)
{
wstring inputFileName( inputFile );
wstring inputFileName( inputFile );
wstring::size_type pos = 0;
static const wstring::size_type npos = -1;
wstring::size_type pos = 0;
static const wstring::size_type npos = -1;
pos = inputFileName.find_last_of( L'\\' );
pos = inputFileName.find_last_of( L'\\' );
wstring zipFileName;
wstring zipFileName;
if ( pos != npos )
{
zipFileName = wstring( ( inputFileName.begin() + pos + 1 ), inputFileName.end() );
}
else
{
zipFileName = wstring( inputFileName.begin(), inputFileName.end() );
}
std::string zipFileNameA = codepage_issue_fixToOEM(zipFileName);
if ( pos != npos )
{
zipFileName = wstring( ( inputFileName.begin() + pos + 1 ), inputFileName.end() );
}
else
{
zipFileName = wstring( inputFileName.begin(), inputFileName.end() );
}
std::string zipFileNameA = codepage_issue_fixToOEM(zipFileName);
err = zipOpenNewFileInZip( zf, zipFileNameA.c_str(), &zinfo, NULL, 0, NULL, 0, NULL, method, compressionLevel );
err = zipWriteInFileInZip( zf, pData, dwSizeRead );
err = zipCloseFileInZip( zf );
err = zipClose( zf, NULL );
err = zipOpenNewFileInZip( zf, zipFileNameA.c_str(), &zinfo, NULL, 0, NULL, 0, NULL, method, compressionLevel );
err = zipWriteInFileInZip( zf, pData, dwSizeRead );
err = zipCloseFileInZip( zf );
err = zipClose( zf, NULL );
}
}
RELEASEARRAYOBJECTS(pData);
}
}
return false;
return err;
}
/*========================================================================================================*/