I have modified my function after your suggestion .. here is the updated code...
{
printf("\nPROGRESS : UNZIP FILE REQUESTED ......\n");
bool bFileUnZipDone(false);
QFile filePath
(zipFilePath
);
if(filePath.exists())
{
printf("\nPROGRESS : UnZipFile - file path exists.");
QuaZip zip(zipFilePath);
zip.setFileNameCodec("WINDOWS-1251");
if(zip.open(QuaZip::mdUnzip))
{
printf("\nPROGRESS : UnZipFile - zip opened successfully.");
// Iterate over all the files found in zip folder.
QuaZipFile file(&zip);
for(bool fileIter = zip.goToFirstFile(); fileIter ; fileIter = zip.goToNextFile())
{
printf("\nPROGRESS : UnZipFile - inside file loop..");
//file.open(QIODevice::ReadOnly);
if(file.
open(QIODevice::ReadOnly,filePassword
))// -- THIS FUNCTION IS NOT WORKING AND PRINTS ERROR IN CONSOLE. {
printf("\nPROGRESS : UnZipFile - zip file opened successfully.");
if(file_str.isEmpty())
{
printf("\nPROGRESS : unzip file data found, saving to a fdisk file...");
bFileUnZipDone = SaveFileToDisk(unzipFilePath, file_data);
}
file.close();
}
}
zip.close();
}
else
{
printf("\n QuaZip open error : %d ",zip.getZipError());
}
}
return bFileUnZipDone;
}
bool CFileManager::UnZipFile(QString zipFilePath, QString unzipFilePath, QString filePassword)
{
printf("\nPROGRESS : UNZIP FILE REQUESTED ......\n");
bool bFileUnZipDone(false);
QFile filePath(zipFilePath);
if(filePath.exists())
{
printf("\nPROGRESS : UnZipFile - file path exists.");
QuaZip zip(zipFilePath);
zip.setFileNameCodec("WINDOWS-1251");
if(zip.open(QuaZip::mdUnzip))
{
printf("\nPROGRESS : UnZipFile - zip opened successfully.");
// Iterate over all the files found in zip folder.
QuaZipFile file(&zip);
for(bool fileIter = zip.goToFirstFile(); fileIter ; fileIter = zip.goToNextFile())
{
printf("\nPROGRESS : UnZipFile - inside file loop..");
//file.open(QIODevice::ReadOnly);
if(file.open(QIODevice::ReadOnly,filePassword))// -- THIS FUNCTION IS NOT WORKING AND PRINTS ERROR IN CONSOLE.
{
printf("\nPROGRESS : UnZipFile - zip file opened successfully.");
QByteArray file_data = file.readAll();
QString file_str(file_data);
if(file_str.isEmpty())
{
printf("\nPROGRESS : unzip file data found, saving to a fdisk file...");
bFileUnZipDone = SaveFileToDisk(unzipFilePath, file_data);
}
file.close();
}
}
zip.close();
}
else
{
printf("\n QuaZip open error : %d ",zip.getZipError());
}
}
return bFileUnZipDone;
}
To copy to clipboard, switch view to plain text mode
Console shows "QuaZipFile:
pen(): open mode 1 not supported by this function" message when it reaches to QuaZipFile open function, marked with capital letter comment in above code.
I would like to unzip file on windows 8.1.
Please help,
Thanks.
Bookmarks