summaryrefslogtreecommitdiff
path: root/apps/shortcuts.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-09-13 01:54:08 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2024-09-13 11:22:46 -0400
commitde355d225cfd074eea6cfa8cd3572d41ddd7cb08 (patch)
treefb6e371ef93c5b9aa475c8cf31950a16fa652cca /apps/shortcuts.c
parent563137b4806d6a6f9168318c010e5255ce15252f (diff)
downloadrockbox-de355d225cfd074eea6cfa8cd3572d41ddd7cb08.tar.gz
rockbox-de355d225cfd074eea6cfa8cd3572d41ddd7cb08.zip
Remove static buffer from shortcts.c
as long as we put it back the way we found it u.path is a writable buffer Change-Id: I6f1e6139ce96b8edb61ad8b0ae6a6f2218eee855
Diffstat (limited to 'apps/shortcuts.c')
-rw-r--r--apps/shortcuts.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/apps/shortcuts.c b/apps/shortcuts.c
index 5453422b43..adac5e3327 100644
--- a/apps/shortcuts.c
+++ b/apps/shortcuts.c
@@ -482,15 +482,15 @@ static int shortcut_menu_speak_item(int selected_item, void * data)
482 { 482 {
483 case SHORTCUT_BROWSER: 483 case SHORTCUT_BROWSER:
484 { 484 {
485 static char path[MAX_PATH];
486 DIR* dir; 485 DIR* dir;
487 struct dirent* entry; 486 struct dirent* entry;
488 char* filename = strrchr(sc->u.path, PATH_SEPCH) + 1; 487 char* slash = strrchr(sc->u.path, PATH_SEPCH);
489 if (*filename != '\0') 488 char* filename = slash + 1;
489 if (slash && *filename != '\0')
490 { 490 {
491 int dirlen = (filename - sc->u.path); 491 *slash = '\0'; /* terminate the path to open the directory */
492 strmemccpy(path, sc->u.path, dirlen + 1); 492 dir = opendir(sc->u.path);
493 dir = opendir(path); 493 *slash = PATH_SEPCH; /* restore fullpath */
494 if (dir) 494 if (dir)
495 { 495 {
496 while (0 != (entry = readdir(dir))) 496 while (0 != (entry = readdir(dir)))
@@ -498,9 +498,12 @@ static int shortcut_menu_speak_item(int selected_item, void * data)
498 if (!strcmp(entry->d_name, filename)) 498 if (!strcmp(entry->d_name, filename))
499 { 499 {
500 struct dirinfo info = dir_get_info(dir, entry); 500 struct dirinfo info = dir_get_info(dir, entry);
501
501 if (info.attribute & ATTR_DIRECTORY) 502 if (info.attribute & ATTR_DIRECTORY)
502 talk_dir_or_spell(sc->u.path, NULL, false); 503 talk_dir_or_spell(sc->u.path, NULL, false);
503 else talk_file_or_spell(path, filename, NULL, false); 504 else
505 talk_file_or_spell(NULL, sc->u.path, NULL, false);
506
504 closedir(dir); 507 closedir(dir);
505 return 0; 508 return 0;
506 } 509 }