diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-09-13 01:54:08 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2024-09-13 11:22:46 -0400 |
commit | de355d225cfd074eea6cfa8cd3572d41ddd7cb08 (patch) | |
tree | fb6e371ef93c5b9aa475c8cf31950a16fa652cca | |
parent | 563137b4806d6a6f9168318c010e5255ce15252f (diff) | |
download | rockbox-de355d225c.tar.gz rockbox-de355d225c.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
-rw-r--r-- | apps/shortcuts.c | 17 |
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) { case SHORTCUT_BROWSER: { - static char path[MAX_PATH]; DIR* dir; struct dirent* entry; - char* filename = strrchr(sc->u.path, PATH_SEPCH) + 1; - if (*filename != '\0') + char* slash = strrchr(sc->u.path, PATH_SEPCH); + char* filename = slash + 1; + if (slash && *filename != '\0') { - int dirlen = (filename - sc->u.path); - strmemccpy(path, sc->u.path, dirlen + 1); - dir = opendir(path); + *slash = '\0'; /* terminate the path to open the directory */ + dir = opendir(sc->u.path); + *slash = PATH_SEPCH; /* restore fullpath */ if (dir) { while (0 != (entry = readdir(dir))) @@ -498,9 +498,12 @@ static int shortcut_menu_speak_item(int selected_item, void * data) if (!strcmp(entry->d_name, filename)) { struct dirinfo info = dir_get_info(dir, entry); + if (info.attribute & ATTR_DIRECTORY) talk_dir_or_spell(sc->u.path, NULL, false); - else talk_file_or_spell(path, filename, NULL, false); + else + talk_file_or_spell(NULL, sc->u.path, NULL, false); + closedir(dir); return 0; } |