Skip to content

Commit

Permalink
Show album cover when playing CUE image file
Browse files Browse the repository at this point in the history
Closes #48
  • Loading branch information
andgera authored and arkq committed May 31, 2022
1 parent cdef839 commit a71742c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,28 @@ char *get_album_cover_file(const char *location, const char *format) {
if (location == NULL)
return NULL;

/* handle cue image file */
bool is_cue_file = false;
if (strncmp(location, "cue://", 6) == 0) {
is_cue_file = true;
location += 6;
}

/* NOTE: We can support absolute paths only. The reason for this, is, that
* cmus might report file name according to its current directory,
* which is not known. Hence this obstruction. */
if (location[0] != '/')
return NULL;

tmp = strdup(location);

strcpy(fname, dirname(tmp));

/* In case of a cue image file strip one more component from the path. The
* cue URI looks like this: cue://<path>/<image-file>/<track-number> */
if (is_cue_file)
dirname(fname);

free(tmp);

if ((dir = opendir(fname)) == NULL)
Expand Down

0 comments on commit a71742c

Please sign in to comment.