diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2023-03-15 06:16:02 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2023-03-24 06:12:01 -0400 |
commit | 5eb24a9582eba2b9036e3f849472bfa0950c7277 (patch) | |
tree | 40810f4e63e24f567cf912ca6bf24e848b56229a | |
parent | 58b2e457824dc93916233627b98614409e5f258d (diff) | |
download | rockbox-5eb24a9582.tar.gz rockbox-5eb24a9582.zip |
playlist: Cleanup get_next_dir()
Pass the direction as a signed integer to avoid jumping through
unnecessary hoops.
Change-Id: I1a36c3804b5f7103464f0d2ee69d060505261274
-rw-r--r-- | apps/playlist.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index c755aca9fd..eef6321f19 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -1021,7 +1021,7 @@ static int check_subdir_for_music(char *dir, const char *subdir, bool recurse) * search through all the directories (starting with the current) to find * one that has tracks to play */ -static int get_next_dir(char *dir, bool is_forward) +static int get_next_dir(char *dir, int direction) { struct playlist_info* playlist = ¤t_playlist; int result = -1; @@ -1103,7 +1103,7 @@ static int get_next_dir(char *dir, bool is_forward) /* set up sorting/direction */ tc->sort_dir = global_settings.sort_dir; - if (!is_forward) + if (direction < 0) { static const char sortpairs[] = { @@ -1199,14 +1199,6 @@ static int get_next_dir(char *dir, bool is_forward) return result; } -static int get_next_directory(char *dir){ - return get_next_dir(dir, true); -} - -static int get_previous_directory(char *dir){ - return get_next_dir(dir, false); -} - /* * gets pathname for track at seek index */ @@ -1314,14 +1306,9 @@ static int get_track_filename(struct playlist_info* playlist, int index, int see static int create_and_play_dir(int direction, bool play_last) { char dir[MAX_PATH + 1]; - int res; + int res = get_next_dir(dir, direction); int index = -1; - if(direction > 0) - res = get_next_directory(dir); - else - res = get_previous_directory(dir); - if (res < 0) /* return the error encountered */ return res; |