bool ThemeLoader::extractZip( const std::string &zipFile, const std::string &rootDir ) { bool b_isWsz = strstr( zipFile.c_str(), ".wsz" ); // Try to open the ZIP file zlib_filefunc_def descr; fill_fopen_filefunc( &descr ); descr.zopen_file = open_vlc; descr.opaque = getIntf(); unzFile file = unzOpen2( zipFile.c_str(), &descr ); if( file == 0 ) { msg_Dbg( getIntf(), "failed to open %s as a zip file", zipFile.c_str() ); return false; } unz_global_info info; if( unzGetGlobalInfo( file, &info ) != UNZ_OK ) { msg_Dbg( getIntf(), "failed to read zip info from %s", zipFile.c_str() ); unzClose( file ); return false; } // Extract all the files in the archive for( unsigned long i = 0; i < info.number_entry; i++ ) { if( !extractFileInZip( file, rootDir, b_isWsz ) ) { msg_Warn( getIntf(), "error while unzipping %s", zipFile.c_str() ); unzClose( file ); return false; } if( i < info.number_entry - 1 ) { // Go the next file in the archive if( unzGoToNextFile( file ) != UNZ_OK ) { msg_Warn( getIntf(), "error while unzipping %s", zipFile.c_str() ); unzClose( file ); return false; } } } unzClose( file ); return true; }
bool ThemeLoader::extractZip( const string &zipFile, const string &rootDir ) { bool b_isWsz = strstr( zipFile.c_str(), ".wsz" ); // Try to open the ZIP file unzFile file = unzOpen( zipFile.c_str() ); unz_global_info info; if( unzGetGlobalInfo( file, &info ) != UNZ_OK ) { return false; } // Extract all the files in the archive for( unsigned long i = 0; i < info.number_entry; i++ ) { if( !extractFileInZip( file, rootDir, b_isWsz ) ) { msg_Warn( getIntf(), "error while unzipping %s", zipFile.c_str() ); unzClose( file ); return false; } if( i < info.number_entry - 1 ) { // Go the next file in the archive if( unzGoToNextFile( file ) !=UNZ_OK ) { msg_Warn( getIntf(), "error while unzipping %s", zipFile.c_str() ); unzClose( file ); return false; } } } unzClose( file ); return true; }