Exemplo n.º 1
0
/**
 * content_playlist_clear:
 * @playlist        	   : Playlist handle.
 *
 * Clears all playlist entries in playlist.
 **/
void content_playlist_clear(content_playlist_t *playlist)
{
   size_t i;
   if (!playlist)
      return;

   for (i = 0; i < playlist->cap; i++)
      content_playlist_free_entry(&playlist->entries[i]);
   playlist->size = 0;
}
Exemplo n.º 2
0
void content_playlist_free(content_playlist_t *playlist)
{
   size_t i;
   if (!playlist)
      return;

   if (playlist->conf_path)
      content_playlist_write_file(playlist);
   free(playlist->conf_path);

   for (i = 0; i < playlist->cap; i++)
      content_playlist_free_entry(&playlist->entries[i]);
   free(playlist->entries);

   free(playlist);
}
Exemplo n.º 3
0
void content_playlist_push(content_playlist_t *playlist,
      const char *path, const char *core_path,
      const char *core_name)
{
   size_t i;

   if (!playlist)
      return;

   for (i = 0; i < playlist->size; i++)
   {
      bool equal_path = (!path && !playlist->entries[i].path) ||
         (path && playlist->entries[i].path &&
          !strcmp(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 && !strcmp(playlist->entries[i].core_path, core_path))
      {
         if (i == 0)
            return;

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

   if (playlist->size == playlist->cap)
   {
      content_playlist_free_entry(&playlist->entries[playlist->cap - 1]);
      playlist->size--;
   }

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

   playlist->entries[0].path      = path ? strdup(path) : NULL;
   playlist->entries[0].core_path = strdup(core_path);
   playlist->entries[0].core_name = strdup(core_name);
   playlist->size++;
}
Exemplo n.º 4
0
/**
 * content_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.
 **/
void content_playlist_push(content_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 (!playlist)
      return;

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

   if (path && !*path)
      path = NULL;

   for (i = 0; i < playlist->size; i++)
   {
      content_playlist_entry_t 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;

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

      return;
   }

   if (playlist->size == playlist->cap)
   {
      content_playlist_free_entry(&playlist->entries[playlist->cap - 1]);
      playlist->size--;
   }

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

   playlist->entries[0].path      = path      ? strdup(path)      : NULL;
   playlist->entries[0].label     = label     ? strdup(label)     : NULL;
   playlist->entries[0].core_path = core_path ? strdup(core_path) : NULL;
   playlist->entries[0].core_name = core_name ? strdup(core_name) : NULL;
   playlist->entries[0].db_name   = db_name   ? strdup(db_name)   : NULL;
   playlist->entries[0].crc32     = crc32     ? strdup(crc32)     : NULL;
   playlist->size++;
}