Пример #1
0
int rarch_extract_zipfile(const char *zip_path)
{
   unzFile uf = unzOpen(zip_path); 

   unz_global_info gi;
   int err = unzGetGlobalInfo(uf, &gi);
   if (err != UNZ_OK)
      RARCH_ERR("error %d with ZIP file in unzGetGlobalInfo \n",err);

   for (unsigned i = 0; i < gi.number_entry; i++)
   {
      if (rarch_extract_currentfile_in_zip(uf) != UNZ_OK)
         break;

      if ((i + 1) < gi.number_entry)
      {
         err = unzGoToNextFile(uf);
         if (err != UNZ_OK)
         {
            RARCH_ERR("error %d with ZIP file in unzGoToNextFile\n",err);
            break;
         }
      }
   }

   if(g_console.info_msg_enable)
      rarch_settings_msg(S_MSG_EXTRACTED_ZIPFILE, S_DELAY_180);

   return 0;
}
Пример #2
0
int rarch_extract_zipfile(const char *zip_path, const char *current_dir, char *first_file, size_t first_file_size, unsigned extract_zip_mode)
{
   bool found_first_file = false;
   (void)found_first_file;
   unzFile uf = unzOpen(zip_path); 

   unz_global_info gi;
   int ret = unzGetGlobalInfo(uf, &gi);
   if(ret != UNZ_OK)
      RARCH_ERR("Error %d while trying to get ZIP file global info.\n", ret);

   for (unsigned i = 0; i < gi.number_entry; i++)
   {
      static char write_filename[PATH_MAX];
      char slash[6];
#ifdef _XBOX
      snprintf(slash, sizeof(slash), "\\");
#else
      snprintf(slash, sizeof(slash), "/");
#endif
      if (rarch_extract_currentfile_in_zip(uf, current_dir, slash, write_filename, sizeof(write_filename), extract_zip_mode) != UNZ_OK)
      {
         RARCH_ERR("Failed to extract current file from ZIP archive.\n");
         break;
      }
      else
      {
#ifdef HAVE_LIBRETRO_MANAGEMENT
         if(!found_first_file)
         {
            found_first_file = rarch_manage_libretro_extension_supported(write_filename);

            if(found_first_file)
               snprintf(first_file, first_file_size, write_filename);
         }
#endif
      }

      if ((i + 1) < gi.number_entry)
      {
         ret = unzGoToNextFile(uf);
         if (ret != UNZ_OK)
         {
            RARCH_ERR("Error %d while trying to go to the next file in the ZIP archive.\n", ret);
            break;
         }
      }
   }

   return 0;
}