@@ -725,72 +725,6 @@ bool Client::loadMedia(const std::string &data, const std::string &filename,
725725 return false ;
726726}
727727
728- bool Client::extractZipFile (const char *filename, const std::string &destination)
729- {
730- auto fs = m_rendering_engine->get_filesystem ();
731-
732- if (!fs->addFileArchive (filename, false , false , io::EFAT_ZIP)) {
733- return false ;
734- }
735-
736- sanity_check (fs->getFileArchiveCount () > 0 );
737-
738- /* *********************************************************************/
739- /* WARNING this is not threadsafe!! */
740- /* *********************************************************************/
741- io::IFileArchive* opened_zip = fs->getFileArchive (fs->getFileArchiveCount () - 1 );
742-
743- const io::IFileList* files_in_zip = opened_zip->getFileList ();
744-
745- unsigned int number_of_files = files_in_zip->getFileCount ();
746-
747- for (unsigned int i=0 ; i < number_of_files; i++) {
748- std::string fullpath = destination;
749- fullpath += DIR_DELIM;
750- fullpath += files_in_zip->getFullFileName (i).c_str ();
751- std::string fullpath_dir = fs::RemoveLastPathComponent (fullpath);
752-
753- if (!files_in_zip->isDirectory (i)) {
754- if (!fs::PathExists (fullpath_dir) && !fs::CreateAllDirs (fullpath_dir)) {
755- fs->removeFileArchive (fs->getFileArchiveCount ()-1 );
756- return false ;
757- }
758-
759- io::IReadFile* toread = opened_zip->createAndOpenFile (i);
760-
761- FILE *targetfile = fopen (fullpath.c_str ()," wb" );
762-
763- if (targetfile == NULL ) {
764- fs->removeFileArchive (fs->getFileArchiveCount ()-1 );
765- return false ;
766- }
767-
768- char read_buffer[1024 ];
769- long total_read = 0 ;
770-
771- while (total_read < toread->getSize ()) {
772-
773- unsigned int bytes_read =
774- toread->read (read_buffer,sizeof (read_buffer));
775- if ((bytes_read == 0 ) ||
776- (fwrite (read_buffer, 1 , bytes_read, targetfile) != bytes_read))
777- {
778- fclose (targetfile);
779- fs->removeFileArchive (fs->getFileArchiveCount () - 1 );
780- return false ;
781- }
782- total_read += bytes_read;
783- }
784-
785- fclose (targetfile);
786- }
787-
788- }
789-
790- fs->removeFileArchive (fs->getFileArchiveCount () - 1 );
791- return true ;
792- }
793-
794728// Virtual methods from con::PeerHandler
795729void Client::peerAdded (con::Peer *peer)
796730{
0 commit comments