diff options
-rw-r--r-- | deadbeef.h | 9 | ||||
-rw-r--r-- | playlist.c | 15 | ||||
-rw-r--r-- | plugins/vfs_zip/vfs_zip.c | 9 |
3 files changed, 28 insertions, 5 deletions
@@ -1374,8 +1374,15 @@ typedef struct DB_vfs_s { // in icy protocol void (*set_track) (DB_FILE *f, DB_playItem_t *it); -// folder access, follows dirent API, and uses dirent data structures + // folder access, follows dirent API, and uses dirent data structures int (*scandir) (const char *dir, struct dirent ***namelist, int (*selector) (const struct dirent *), int (*cmp) (const struct dirent **, const struct dirent **)); + +#if (DDB_API_LEVEL >= 6) + // returns URI scheme for a given file name, e.g. "zip://" + // can be NULL + // can return NULL + const char *(*get_scheme_for_name) (const char *fname); +#endif } DB_vfs_t; // gui plugin @@ -1481,10 +1481,21 @@ plt_insert_dir_int (int visibility, playlist_t *playlist, DB_vfs_t *vfs, playIte } } else { - inserted = plt_insert_file_int (visibility, playlist, after, namelist[i]->d_name, pabort, cb, user_data); + char fullname[PATH_MAX]; + const char *sch = NULL; + if (vfs->plugin.api_vminor >= 6 && vfs->get_scheme_for_name) { + sch = vfs->get_scheme_for_name (dirname); + } + if (sch && strncmp (sch, namelist[i]->d_name, strlen (sch))) { + snprintf (fullname, sizeof (fullname), "%s%s:%s", sch, dirname, namelist[i]->d_name); + } + else { + strcpy (fullname, namelist[i]->d_name); + } + inserted = plt_insert_file_int (visibility, playlist, after, fullname, pabort, cb, user_data); if (!inserted) { // special case for loading playlists in zip files - inserted = plt_load_int (visibility, playlist, after, namelist[i]->d_name, pabort, cb, user_data); + inserted = plt_load_int (visibility, playlist, after, fullname, pabort, cb, user_data); } } if (inserted) { diff --git a/plugins/vfs_zip/vfs_zip.c b/plugins/vfs_zip/vfs_zip.c index eddd1cd0..65bcb25d 100644 --- a/plugins/vfs_zip/vfs_zip.c +++ b/plugins/vfs_zip/vfs_zip.c @@ -196,7 +196,7 @@ vfs_zip_scandir (const char *dir, struct dirent ***namelist, int (*selector) (co (*namelist)[i] = malloc (sizeof (struct dirent)); memset ((*namelist)[i], 0, sizeof (struct dirent)); const char *nm = zip_get_name (z, i, 0); - snprintf ((*namelist)[i]->d_name, sizeof ((*namelist)[i]->d_name), "zip://%s:%s", dir, nm); + snprintf ((*namelist)[i]->d_name, sizeof ((*namelist)[i]->d_name), "%s", nm); } zip_close (z); @@ -211,10 +211,14 @@ vfs_zip_is_container (const char *fname) { } return 0; } +const char * +vfs_zip_get_scheme_for_name (const char *fname) { + return scheme_names[0]; +} static DB_vfs_t plugin = { .plugin.api_vmajor = 1, - .plugin.api_vminor = 0, + .plugin.api_vminor = 6, .plugin.version_major = 1, .plugin.version_minor = 0, .plugin.type = DB_PLUGIN_VFS, @@ -250,6 +254,7 @@ static DB_vfs_t plugin = { .is_streaming = vfs_zip_is_streaming, .is_container = vfs_zip_is_container, .scandir = vfs_zip_scandir, + .get_scheme_for_name = vfs_zip_get_scheme_for_name, }; DB_plugin_t * |