コード例 #1
0
ファイル: core_info.c プロジェクト: Zarh/RetroArch
static bool core_info_list_iterate(
      char *s, size_t len,
      struct string_list *contents, size_t i)
{
   char info_path_base[PATH_MAX_LENGTH];
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA))
   char                       *substr   = NULL;
#endif
   settings_t                 *settings = config_get_ptr();

   if (!contents || !contents->elems[i].data)
      return false;

   info_path_base[0] = '\0';

   fill_pathname_base_noext(info_path_base, contents->elems[i].data,
         sizeof(info_path_base));

#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(HW_WUP))
   substr = strrchr(info_path_base, '_');
   if (substr)
      *substr = '\0';
#endif

   strlcat(info_path_base,
         file_path_str(FILE_PATH_CORE_INFO_EXTENSION),
         sizeof(info_path_base));

   fill_pathname_join(s,
         (!string_is_empty(settings->paths.path_libretro_info)) ?
         settings->paths.path_libretro_info : settings->paths.directory_libretro,
         info_path_base, len);

   return true;
}
コード例 #2
0
ファイル: core_info.c プロジェクト: KitoHo/RetroArch
static config_file_t *core_info_list_iterate(
      struct string_list *contents, size_t i)
{
   char info_path_base[PATH_MAX_LENGTH] = {0};
   char info_path[PATH_MAX_LENGTH]      = {0};
   settings_t                 *settings = config_get_ptr();

   if (!contents->elems[i].data)
      return NULL;

   fill_pathname_base_noext(info_path_base, contents->elems[i].data,
         sizeof(info_path_base));

#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA))
   char *substr = strrchr(info_path_base, '_');
   if (substr)
      *substr = '\0';
#endif

   strlcat(info_path_base,
         file_path_str(FILE_PATH_CORE_INFO_EXTENSION),
         sizeof(info_path_base));

   fill_pathname_join(info_path,
         (!string_is_empty(settings->path.libretro_info)) ?
         settings->path.libretro_info : settings->directory.libretro,
         info_path_base, sizeof(info_path));

   return config_file_new(info_path);
}
コード例 #3
0
ファイル: core_info.c プロジェクト: DSkywalk/RetroArch
static bool core_info_list_iterate(
      char *s, size_t len,
      const char *path_basedir,
      struct string_list *contents, size_t i)
{
   size_t info_path_base_size = PATH_MAX_LENGTH * sizeof(char);
   char *info_path_base       = NULL;
   char             *substr   = NULL;
   const char *current_path   = contents ? contents->elems[i].data : NULL;

   (void)substr;

   if (!current_path)
      return false;

   info_path_base             = (char*)malloc(info_path_base_size);

   info_path_base[0] = '\0';

   fill_pathname_base_noext(info_path_base,
         current_path,
         info_path_base_size);

#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(PS2) && !defined(HW_WUP))
   substr = strrchr(info_path_base, '_');
   if (substr)
      *substr = '\0';
#endif

   strlcat(info_path_base,
         file_path_str(FILE_PATH_CORE_INFO_EXTENSION),
         info_path_base_size);

   fill_pathname_join(s,
         path_basedir,
         info_path_base, len);

   free(info_path_base);
   return true;
}
コード例 #4
0
ファイル: file_path.c プロジェクト: heuripedes/RetroArch
void fill_pathname_base_ext(char *out, const char *in_path, const char *ext,
                            size_t size)
{
    fill_pathname_base_noext(out, in_path, size);
    strlcat(out, ext, size);
}
コード例 #5
0
ファイル: ozone_sidebar.c プロジェクト: DSkywalk/RetroArch
void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
{
   unsigned i;
   const char *title;
   char title_noext[255];
   char *chr;
   bool hyphen_found;

   size_t list_size  = ozone_list_get_size(ozone, MENU_LIST_HORIZONTAL);

   for (i = 0; i < list_size; i++)
   {
      const char *path     = NULL;
      ozone_node_t *node   = (ozone_node_t*)file_list_get_userdata_at_offset(ozone->horizontal_list, i);

      if (!node)
      {
         node = ozone_alloc_node();
         if (!node)
            continue;
      }

      file_list_get_at_offset(ozone->horizontal_list, i,
            &path, NULL, NULL, NULL);

      if (!path)
         continue;

      if (!strstr(path, file_path_str(FILE_PATH_LPL_EXTENSION)))
         continue;

      {
         struct texture_image ti;
         char *sysname             = (char*)
            malloc(PATH_MAX_LENGTH * sizeof(char));
         char *texturepath         = (char*)
            malloc(PATH_MAX_LENGTH * sizeof(char));
         char *content_texturepath = (char*)
            malloc(PATH_MAX_LENGTH * sizeof(char));
         char *icons_path          = (char*)
            malloc(PATH_MAX_LENGTH * sizeof(char));

         strlcpy(icons_path, ozone->icons_path, PATH_MAX_LENGTH * sizeof(char));

         sysname[0] = texturepath[0] = content_texturepath[0] = '\0';

         fill_pathname_base_noext(sysname, path,
               PATH_MAX_LENGTH * sizeof(char));

         fill_pathname_join_concat(texturepath, icons_path, sysname,
               file_path_str(FILE_PATH_PNG_EXTENSION),
               PATH_MAX_LENGTH * sizeof(char));

         /* If the playlist icon doesn't exist return default */

         if (!filestream_exists(texturepath))
               fill_pathname_join_concat(texturepath, icons_path, "default",
               file_path_str(FILE_PATH_PNG_EXTENSION),
               PATH_MAX_LENGTH * sizeof(char));

         ti.width         = 0;
         ti.height        = 0;
         ti.pixels        = NULL;
         ti.supports_rgba = video_driver_supports_rgba();

         if (image_texture_load(&ti, texturepath))
         {
            if(ti.pixels)
            {
               video_driver_texture_unload(&node->icon);
               video_driver_texture_load(&ti,
                     TEXTURE_FILTER_MIPMAP_LINEAR, &node->icon);
            }

            image_texture_free(&ti);
         }

         fill_pathname_join_delim(sysname, sysname,
               file_path_str(FILE_PATH_CONTENT_BASENAME), '-',
               PATH_MAX_LENGTH * sizeof(char));
         strlcat(content_texturepath, icons_path, PATH_MAX_LENGTH * sizeof(char));

         strlcat(content_texturepath, path_default_slash(), PATH_MAX_LENGTH * sizeof(char));
         strlcat(content_texturepath, sysname, PATH_MAX_LENGTH * sizeof(char));

         /* If the content icon doesn't exist return default-content */
         if (!filestream_exists(content_texturepath))
         {
            strlcat(icons_path, path_default_slash(), PATH_MAX_LENGTH * sizeof(char));
            strlcat(icons_path, "default", PATH_MAX_LENGTH * sizeof(char));
            fill_pathname_join_delim(content_texturepath, icons_path,
                  file_path_str(FILE_PATH_CONTENT_BASENAME), '-',
                  PATH_MAX_LENGTH * sizeof(char));
         }

         if (image_texture_load(&ti, content_texturepath))
         {
            if(ti.pixels)
            {
               video_driver_texture_unload(&node->content_icon);
               video_driver_texture_load(&ti,
                     TEXTURE_FILTER_MIPMAP_LINEAR, &node->content_icon);
            }

            image_texture_free(&ti);
         }

         /* Console name */
         menu_entries_get_at_offset(
            ozone->horizontal_list,
            i,
            &title, NULL, NULL, NULL, NULL);

         fill_pathname_base_noext(title_noext, title, sizeof(title_noext));

         /* Format : "Vendor - Console"
            Remove everything before the hyphen
            and the subsequent space */
         chr          = title_noext;
         hyphen_found = false;

         while (true)
         {
            if (*chr == '-')
            {
               hyphen_found = true;
               break;
            }
            else if (*chr == '\0')
               break;

            chr++;
         }

         if (hyphen_found)
            chr += 2;
         else
            chr = title_noext;

         if (node->console_name)
            free(node->console_name);

         node->console_name = strdup(chr);

         free(sysname);
         free(texturepath);
         free(content_texturepath);
         free(icons_path);
      }
   }
}
コード例 #6
0
ファイル: playlist.c プロジェクト: Monroe88/RetroArch
/**
 * playlist_push:
 * @playlist        	   : Playlist handle.
 * @path                : Path of new playlist entry.
 * @core_path           : Core path of new playlist entry.
 * @core_name           : Core name of new playlist entry.
 *
 * Push entry to top of playlist.
 **/
bool playlist_push(playlist_t *playlist,
      const char *path, const char *label,
      const char *core_path, const char *core_name,
      const char *crc32,
      const char *db_name)
{
   size_t i;
   bool core_path_empty = string_is_empty(core_path);
   bool core_name_empty = string_is_empty(core_name);

   if (core_path_empty || core_name_empty)
   {
      if (core_name_empty && !core_path_empty)
      {
         static char base_path[255] = {0};
         fill_pathname_base_noext(base_path, core_path, sizeof(base_path));
         core_name = base_path;
      }

      if (core_path_empty || core_name_empty)
      {
         RARCH_ERR("cannot push NULL or empty core name into the playlist.\n");
         return false;
      }
   }

   if (string_is_empty(path))
      path = NULL;

   if (!playlist)
      return false;

   for (i = 0; i < playlist->size; i++)
   {
      struct playlist_entry tmp;
      bool equal_path;

      equal_path = (!path && !playlist->entries[i].path) ||
         (path && playlist->entries[i].path &&
#ifdef _WIN32
          /*prevent duplicates on case-insensitive operating systems*/
          string_is_equal_noncase(path,playlist->entries[i].path)
#else
          string_is_equal(path,playlist->entries[i].path)
#endif
          );

      /* Core name can have changed while still being the same core.
       * Differentiate based on the core path only. */
      if (!equal_path)
         continue;

      if (!string_is_equal(playlist->entries[i].core_path, core_path))
         continue;

      /* If top entry, we don't want to push a new entry since
       * the top and the entry to be pushed are the same. */
      if (i == 0)
         return false;

      /* Seen it before, bump to top. */
      tmp = playlist->entries[i];
      memmove(playlist->entries + 1, playlist->entries,
            i * sizeof(struct playlist_entry));
      playlist->entries[0] = tmp;

      goto success;
   }

   if (playlist->size == playlist->cap)
   {
      struct playlist_entry *entry = &playlist->entries[playlist->cap - 1];

      if (entry)
         playlist_free_entry(entry);
      playlist->size--;
   }

   if (playlist->entries)
   {
      memmove(playlist->entries + 1, playlist->entries,
            (playlist->cap - 1) * sizeof(struct playlist_entry));

      playlist->entries[0].path         = NULL;
      playlist->entries[0].label        = NULL;
      playlist->entries[0].core_path    = NULL;
      playlist->entries[0].core_name    = NULL;
      playlist->entries[0].db_name      = NULL;
      playlist->entries[0].crc32        = NULL;
      if (!string_is_empty(path))
         playlist->entries[0].path      = strdup(path);
      if (!string_is_empty(label))
         playlist->entries[0].label     = strdup(label);
      if (!string_is_empty(core_path))
         playlist->entries[0].core_path = strdup(core_path);
      if (!string_is_empty(core_name))
         playlist->entries[0].core_name = strdup(core_name);
      if (!string_is_empty(db_name))
         playlist->entries[0].db_name   = strdup(db_name);
      if (!string_is_empty(crc32))
         playlist->entries[0].crc32     = strdup(crc32);
   }

   playlist->size++;

success:
   playlist->modified = true;

   return true;
}
コード例 #7
0
ファイル: playlist.c プロジェクト: dankcushions/RetroArch
/**
 * playlist_push:
 * @playlist        	   : Playlist handle.
 * @path                : Path of new playlist entry.
 * @core_path           : Core path of new playlist entry.
 * @core_name           : Core name of new playlist entry.
 *
 * Push entry to top of playlist.
 **/
bool playlist_push(playlist_t *playlist,
      const char *path, const char *label,
      const char *core_path, const char *core_name,
      const char *crc32,
      const char *db_name)
{
   size_t i;

   if (string_is_empty(core_path) || string_is_empty(core_name))
   {
      if (string_is_empty(core_name) && !string_is_empty(core_path))
      {
         static char base_path[255] = {0};
         fill_pathname_base_noext(base_path, core_path, sizeof(base_path));
         core_name = base_path;
         RARCH_LOG("core_name is now: %s\n", core_name);
      }

      RARCH_LOG("core_name: %s.\n", string_is_empty(core_name) ? "N/A" : core_name);
      RARCH_LOG("core_path: %s.\n", string_is_empty(core_path) ? "N/A" : core_path);

      if (string_is_empty(core_path) || string_is_empty(core_name))
      {
         RARCH_ERR("cannot push NULL or empty core name into the playlist.\n");
         return false;
      }
   }

   if (string_is_empty(path))
      path = NULL;

   if (!playlist)
      return false;

   for (i = 0; i < playlist->size; i++)
   {
      struct playlist_entry tmp;
      bool equal_path = (!path && !playlist->entries[i].path) ||
         (path && playlist->entries[i].path &&
          string_is_equal(path,playlist->entries[i].path));

      /* Core name can have changed while still being the same core.
       * Differentiate based on the core path only. */
      if (!equal_path)
         continue;

      if (!string_is_equal(playlist->entries[i].core_path, core_path))
         continue;

      /* If top entry, we don't want to push a new entry since
       * the top and the entry to be pushed are the same. */
      if (i == 0)
         return false;

      /* Seen it before, bump to top. */
      tmp = playlist->entries[i];
      memmove(playlist->entries + 1, playlist->entries,
            i * sizeof(struct playlist_entry));
      playlist->entries[0] = tmp;

      return true;
   }

   if (playlist->size == playlist->cap)
   {
      struct playlist_entry *entry = &playlist->entries[playlist->cap - 1];

      if (entry)
         playlist_free_entry(entry);
      playlist->size--;
   }

   memmove(playlist->entries + 1, playlist->entries,
         (playlist->cap - 1) * sizeof(struct playlist_entry));

   playlist->entries[0].path         = NULL;
   playlist->entries[0].label        = NULL;
   playlist->entries[0].core_path    = NULL;
   playlist->entries[0].core_name    = NULL;
   playlist->entries[0].db_name      = NULL;
   playlist->entries[0].crc32        = NULL;
   if (!string_is_empty(path))
      playlist->entries[0].path      = strdup(path);
   if (!string_is_empty(label))
      playlist->entries[0].label     = strdup(label);
   if (!string_is_empty(core_path))
      playlist->entries[0].core_path = strdup(core_path);
   if (!string_is_empty(core_name))
      playlist->entries[0].core_name = strdup(core_name);
   if (!string_is_empty(db_name))
      playlist->entries[0].db_name   = strdup(db_name);
   if (!string_is_empty(crc32))
      playlist->entries[0].crc32     = strdup(crc32);

   playlist->size++;

   return true;
}