mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
Hide extension in Rename dialog when viewing single file type
Hides the file name extension when renaming a file in places other than the File Browser, such as in the Playlists menu, where only a single file type is displayed. Otherwise, a file can disappear from view if its extension is accidentally changed. Plus, it becomes a little easier to edit playlist names, because you don't have to skip past the extension in the keyboard picker anymore. Change-Id: I39fc2b008d5504080e0aa728acf88ceedc2b4617
This commit is contained in:
parent
d9feabc720
commit
5c2a33bba3
1 changed files with 10 additions and 0 deletions
|
@ -613,6 +613,7 @@ int rename_file(const char *selected_file)
|
|||
{
|
||||
int rc;
|
||||
char newname[MAX_PATH];
|
||||
char *newext = NULL;
|
||||
const char *oldbase, *selection = selected_file;
|
||||
|
||||
path_basename(selection, &oldbase);
|
||||
|
@ -622,11 +623,20 @@ int rename_file(const char *selected_file)
|
|||
if (strmemccpy(newname, selection, sizeof (newname)) == NULL)
|
||||
return FORC_PATH_TOO_LONG;
|
||||
|
||||
if ((*tree_get_context()->dirfilter > NUM_FILTER_MODES) &&
|
||||
(newext = strrchr(newbase, '.')))
|
||||
/* hide extension when renaming in lists restricted to a
|
||||
single file format, such as in the Playlists menu */
|
||||
*newext = '\0';
|
||||
|
||||
rc = prompt_name(newbase, sizeof (newname) - pathlen);
|
||||
|
||||
if (rc != FORC_SUCCESS)
|
||||
return rc;
|
||||
|
||||
if (newext) /* re-add original extension */
|
||||
strlcat(newbase, strrchr(selection, '.'), sizeof (newname) - pathlen);
|
||||
|
||||
if (!strcmp(oldbase, newbase))
|
||||
return FORC_NOOP; /* No change at all */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue