Skip to content

Commit

Permalink
Fixes build after reverts
Browse files Browse the repository at this point in the history
Change-Id: I563aba3550940df0c54b321d10d3516bdedf1a16
  • Loading branch information
bahusoid committed Mar 6, 2024
1 parent 0dbd5aa commit b51c44d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
1 change: 0 additions & 1 deletion apps/onplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ static bool shuffle_playlist(void)
return false;
playlist_sort(NULL, true);
playlist_randomise(NULL, current_tick, true);
playlist_set_modified(NULL, true);

return false;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ static const struct plugin_api rockbox_api = {
playlist_amount,
playlist_resume,
playlist_resume_track,
playlist_set_modified,
playlist_start,
playlist_add,
playlist_sync,
Expand Down Expand Up @@ -836,7 +835,8 @@ static const struct plugin_api rockbox_api = {
#ifdef HAVE_TAGCACHE
tagcache_commit_finalize,
#endif
adjust_volume,
playlist_get_first_index,
playlist_get_display_index,
};

static int plugin_buffer_handle;
Expand Down
4 changes: 2 additions & 2 deletions apps/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,6 @@ struct plugin_api {
int (*playlist_resume)(void);
void (*playlist_resume_track)(int start_index, unsigned int crc,
unsigned long elapsed, unsigned long offset);
void (*playlist_set_modified)(struct playlist_info *playlist, bool modified);
void (*playlist_start)(int start_index, unsigned long elapsed,
unsigned long offset);
int (*playlist_add)(const char *filename);
Expand Down Expand Up @@ -973,7 +972,8 @@ struct plugin_api {
#ifdef HAVE_TAGCACHE
void (*tagcache_commit_finalize)(void);
#endif
void (*adjust_volume)(int steps);
int (*playlist_get_first_index)(const struct playlist_info* playlist);
int (*playlist_get_display_index)(void);
};

/* plugin header */
Expand Down
10 changes: 4 additions & 6 deletions apps/screens.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,10 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
playlist_name(info->playlist, buffer, buffer_len);
else
{
if (playlist_allow_dirplay(NULL))
strmemccpy(buffer, "(Folder)", buffer_len);
else if (playlist_dynamic_only())
strmemccpy(buffer, "(Dynamic)", buffer_len);
else
playlist_name(NULL, buffer, buffer_len);
if(!playlist_name(NULL, buffer, buffer_len))
{
strmemccpy(buffer, pl_modified ? "(Dynamic)" : "(Folder)", buffer_len);
}
}

if(say_it)
Expand Down
29 changes: 25 additions & 4 deletions firmware/common/pathfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,16 +448,22 @@ void path_remove_dot_segments (char *dstpath, const char *path)
}

/* Appends one path to another, adding separators between components if needed.
* basepath_max can be used to truncate the basepath if desired
* NOTE: basepath is truncated after copying to the buffer so there must be enough
* free space for the entirety of the basepath even if the resulting string would fit
*
* Return value and behavior is otherwise as strlcpy so that truncation may be
* detected.
*
* For basepath and component:
* PA_SEP_HARD adds a separator even if the base path is empty
* PA_SEP_SOFT adds a separator only if the base path is not empty
*/
size_t path_append(char *buf, const char *basepath,
size_t path_append_ex(char *buf, const char *basepath, size_t basepath_max,
const char *component, size_t bufsize)
{
size_t len;
bool separate = false;
const char *base = basepath && basepath[0] ? basepath : buf;
if (!base)
return bufsize; /* won't work to get lengths from buf */
Expand All @@ -475,11 +481,20 @@ size_t path_append(char *buf, const char *basepath,

/* if basepath is not null or empty, buffer contents are replaced,
otherwise buf contains the base path */
size_t len = base == buf ? strlen(buf) : strlcpy(buf, basepath, bufsize);

bool separate = false;
if (base == buf)
len = strlen(buf);
else
{
len = strlcpy(buf, basepath, bufsize);
if (basepath_max < len)
{
len = basepath_max;
buf[basepath_max] = '\0';
}
}

if (!basepath || !component)
if (!basepath || !component || basepath_max == 0)
separate = !len || base[len-1] != PATH_SEPCH;
else if (component[0])
separate = len && base[len-1] != PATH_SEPCH;
Expand All @@ -497,6 +512,12 @@ size_t path_append(char *buf, const char *basepath,
return len + strlcpy(buf, component ?: "", bufsize);
}


size_t path_append(char *buf, const char *basepath,
const char *component, size_t bufsize)
{
return path_append_ex(buf, basepath, -1u, component, bufsize);
}
/* Returns the location and length of the next path component, consuming the
* input in the process.
*
Expand Down
2 changes: 2 additions & 0 deletions firmware/export/pathfuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ void path_remove_dot_segments(char *dstpath, const char *path);
/* constants useable in basepath and component */
#define PA_SEP_HARD NULL /* separate even if base is empty */
#define PA_SEP_SOFT "" /* separate only if base is nonempty */
size_t path_append_ex(char *buf, const char *basepath, size_t basepath_max,
const char *component, size_t bufsize);
size_t path_append(char *buffer, const char *basepath, const char *component,
size_t bufsize);
ssize_t parse_path_component(const char **pathp, const char **namep);
Expand Down

0 comments on commit b51c44d

Please sign in to comment.