X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=17661c2421daea99821362e2904626c805281507;hb=a049e8267fabd101cb5c6528b3270214cb0647f0;hp=c0da27e4446d38d7b925e47ab637baefa3c32f7e;hpb=de85bc9227ef0db01854fa0eef89256646b4d578;p=dragonfireclient.git diff --git a/src/client/client.cpp b/src/client/client.cpp index c0da27e44..17661c242 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -210,6 +210,9 @@ void Client::scanModSubfolder(const std::string &mod_name, const std::string &mo std::string full_path = mod_path + DIR_DELIM + mod_subpath; std::vector mod = fs::GetDirListing(full_path); for (const fs::DirListNode &j : mod) { + if (j.name[0] == '.') + continue; + if (j.dir) { scanModSubfolder(mod_name, mod_path, mod_subpath + j.name + DIR_DELIM); continue; @@ -725,72 +728,6 @@ bool Client::loadMedia(const std::string &data, const std::string &filename, return false; } -bool Client::extractZipFile(const char *filename, const std::string &destination) -{ - auto fs = m_rendering_engine->get_filesystem(); - - if (!fs->addFileArchive(filename, false, false, io::EFAT_ZIP)) { - return false; - } - - sanity_check(fs->getFileArchiveCount() > 0); - - /**********************************************************************/ - /* WARNING this is not threadsafe!! */ - /**********************************************************************/ - io::IFileArchive* opened_zip = fs->getFileArchive(fs->getFileArchiveCount() - 1); - - const io::IFileList* files_in_zip = opened_zip->getFileList(); - - unsigned int number_of_files = files_in_zip->getFileCount(); - - for (unsigned int i=0; i < number_of_files; i++) { - std::string fullpath = destination; - fullpath += DIR_DELIM; - fullpath += files_in_zip->getFullFileName(i).c_str(); - std::string fullpath_dir = fs::RemoveLastPathComponent(fullpath); - - if (!files_in_zip->isDirectory(i)) { - if (!fs::PathExists(fullpath_dir) && !fs::CreateAllDirs(fullpath_dir)) { - fs->removeFileArchive(fs->getFileArchiveCount()-1); - return false; - } - - io::IReadFile* toread = opened_zip->createAndOpenFile(i); - - FILE *targetfile = fopen(fullpath.c_str(),"wb"); - - if (targetfile == NULL) { - fs->removeFileArchive(fs->getFileArchiveCount()-1); - return false; - } - - char read_buffer[1024]; - long total_read = 0; - - while (total_read < toread->getSize()) { - - unsigned int bytes_read = - toread->read(read_buffer,sizeof(read_buffer)); - if ((bytes_read == 0 ) || - (fwrite(read_buffer, 1, bytes_read, targetfile) != bytes_read)) - { - fclose(targetfile); - fs->removeFileArchive(fs->getFileArchiveCount() - 1); - return false; - } - total_read += bytes_read; - } - - fclose(targetfile); - } - - } - - fs->removeFileArchive(fs->getFileArchiveCount() - 1); - return true; -} - // Virtual methods from con::PeerHandler void Client::peerAdded(con::Peer *peer) {