Beispiel #1
0
static bool content_file_init_extract(
      struct string_list *content,
      content_information_ctx_t *content_ctx,
      const struct retro_subsystem_info *special,
      union string_list_elem_attr *attr,
      char **error_string
      )
{
   unsigned i;

   for (i = 0; i < content->size; i++)
   {
      char temp_content[PATH_MAX_LENGTH];
      char new_path[PATH_MAX_LENGTH];
      bool block_extract                 = content->elems[i].attr.i & 1;
      const char *path                   = content->elems[i].data;
      const char *valid_ext              = special ?
                                           special->roms[i].valid_extensions :
                                           content_ctx->valid_extensions;
      bool contains_compressed           = path_contains_compressed_file(path);

      /* Block extract check. */
      if (block_extract)
         continue;

      /* just use the first file in the archive */
      if (!contains_compressed && !path_is_compressed_file(path))
         continue;

      temp_content[0] = new_path[0] = '\0';

      strlcpy(temp_content, path, sizeof(temp_content));

      if (!valid_ext || !file_archive_extract_file(
               temp_content,
               sizeof(temp_content),
               valid_ext,
               !string_is_empty(content_ctx->directory_cache) ?
               content_ctx->directory_cache : NULL,
               new_path,
               sizeof(new_path)))
      {
         char str[1024];

         snprintf(str, sizeof(str), "%s: %s.\n",
               msg_hash_to_str(
                  MSG_FAILED_TO_EXTRACT_CONTENT_FROM_COMPRESSED_FILE),
               temp_content);
         return false;
      }

      string_list_set(content, i, new_path);

      if (!string_list_append(content_ctx->temporary_content,
               new_path, *attr))
         return false;
   }

   return true;
}
Beispiel #2
0
static bool init_content_file_extract(
      struct string_list *temporary_content,
      struct string_list *content,
      const struct retro_subsystem_info *special,
      union string_list_elem_attr *attr
      )
{
   unsigned i;
   settings_t *settings        = config_get_ptr();
   rarch_system_info_t *system = NULL;

   runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);

   for (i = 0; i < content->size; i++)
   {
      char temp_content[PATH_MAX_LENGTH];
      char new_path[PATH_MAX_LENGTH];
      bool contains_compressed           = NULL;
      bool block_extract                 = content->elems[i].attr.i & 1;
      const char *valid_ext              = system->info.valid_extensions;

      /* Block extract check. */
      if (block_extract)
         continue;

      contains_compressed   = path_contains_compressed_file(content->elems[i].data);

      if (special)
         valid_ext          = special->roms[i].valid_extensions;

      if (!contains_compressed)
      {
         /* just use the first file in the archive */
         if (!path_is_compressed_file(content->elems[i].data))
            continue;
      }

      temp_content[0] = new_path[0] = '\0';

      strlcpy(temp_content, content->elems[i].data,
            sizeof(temp_content));

      if (!valid_ext || !file_archive_extract_file(temp_content,
               sizeof(temp_content), valid_ext,
               *settings->directory.cache ?
               settings->directory.cache : NULL,
               new_path, sizeof(new_path)))
      {
         RARCH_ERR("%s: %s.\n",
               msg_hash_to_str(
                  MSG_FAILED_TO_EXTRACT_CONTENT_FROM_COMPRESSED_FILE),
               temp_content);
         runloop_msg_queue_push(
               msg_hash_to_str(MSG_FAILED_TO_EXTRACT_CONTENT_FROM_COMPRESSED_FILE)
               , 2, 180, true);
         return false;
      }

      string_list_set(content, i, new_path);
      if (!string_list_append(temporary_content,
               new_path, *attr))
         return false;
   }

   return true;
}