forked from len0rd/rockbox
Accept FS#8469 by Bryan Childs with a few adjustments: Remove duplicate strip_extension() function from albumart.c. The other one is moved from tree.c to misc.c.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16103 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
905d80619c
commit
536b5a0482
4 changed files with 25 additions and 48 deletions
19
apps/misc.c
19
apps/misc.c
|
@ -1120,3 +1120,22 @@ bool dir_exists(const char *path)
|
||||||
closedir(d);
|
closedir(d);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* removes the extension of filename (if it doesn't start with a .)
|
||||||
|
* puts the result in buffer
|
||||||
|
*/
|
||||||
|
char *strip_extension(const char *filename, char *buffer)
|
||||||
|
{
|
||||||
|
int dotpos;
|
||||||
|
char *dot = strrchr(filename, '.');
|
||||||
|
if (dot != 0 && filename[0] != '.')
|
||||||
|
{
|
||||||
|
dotpos = dot - filename;
|
||||||
|
strncpy(buffer, filename, dotpos);
|
||||||
|
buffer[dotpos] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcpy(buffer, filename);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
|
@ -118,5 +118,10 @@ char* strrsplt(char* str, int c);
|
||||||
bool file_exists(const char *file);
|
bool file_exists(const char *file);
|
||||||
bool dir_exists(const char *path);
|
bool dir_exists(const char *path);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* removes the extension of filename (if it doesn't start with a .)
|
||||||
|
* puts the result in buffer
|
||||||
|
*/
|
||||||
|
char *strip_extension(const char *filename, char *buffer);
|
||||||
|
|
||||||
#endif /* MISC_H */
|
#endif /* MISC_H */
|
||||||
|
|
|
@ -62,34 +62,6 @@ static char* strip_filename(char* buf, int buf_size, const char* fullpath)
|
||||||
return (sep + 1);
|
return (sep + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strip extension from a filename.
|
|
||||||
*
|
|
||||||
* buf - buffer to output the result to.
|
|
||||||
* buf_size - size of the output buffer buffer.
|
|
||||||
* file - filename to strip extension from.
|
|
||||||
*
|
|
||||||
* Return value is a pointer to buf, which contains the result.
|
|
||||||
*/
|
|
||||||
static char* strip_extension(char* buf, int buf_size, const char* file)
|
|
||||||
{
|
|
||||||
char* sep;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
if (!buf || buf_size <= 0 || !file)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
buf[0] = 0;
|
|
||||||
|
|
||||||
sep = strrchr(file,'.');
|
|
||||||
if (sep == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
len = MIN(sep - file, buf_size - 1);
|
|
||||||
strncpy(buf, file, len);
|
|
||||||
buf[len] = 0;
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure part of path only contain chars valid for a FAT32 long name.
|
/* Make sure part of path only contain chars valid for a FAT32 long name.
|
||||||
* Double quotes are replaced with single quotes, other unsupported chars
|
* Double quotes are replaced with single quotes, other unsupported chars
|
||||||
* are replaced with an underscore.
|
* are replaced with an underscore.
|
||||||
|
@ -144,7 +116,7 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string,
|
||||||
albumlen = id3->album ? strlen(id3->album) : 0;
|
albumlen = id3->album ? strlen(id3->album) : 0;
|
||||||
|
|
||||||
/* the first file we look for is one specific to the track playing */
|
/* the first file we look for is one specific to the track playing */
|
||||||
strip_extension(path, sizeof(path) - strlen(size_string) - 4, trackname);
|
strip_extension(trackname, path);
|
||||||
strcat(path, size_string);
|
strcat(path, size_string);
|
||||||
strcat(path, ".bmp");
|
strcat(path, ".bmp");
|
||||||
found = file_exists(path);
|
found = file_exists(path);
|
||||||
|
|
19
apps/tree.c
19
apps/tree.c
|
@ -115,25 +115,6 @@ static int ft_play_dirname(char* name);
|
||||||
static void ft_play_filename(char *dir, char *file);
|
static void ft_play_filename(char *dir, char *file);
|
||||||
static void say_filetype(int attr);
|
static void say_filetype(int attr);
|
||||||
|
|
||||||
/*
|
|
||||||
* removes the extension of filename (if it doesn't start with a .)
|
|
||||||
* puts the result in buffer
|
|
||||||
*/
|
|
||||||
static char * strip_extension(char * filename, char * buffer)
|
|
||||||
{
|
|
||||||
int dotpos;
|
|
||||||
char * dot=strrchr(filename, '.');
|
|
||||||
if(dot!=0 && filename[0]!='.')
|
|
||||||
{
|
|
||||||
dotpos = dot-filename;
|
|
||||||
strncpy(buffer, filename, dotpos);
|
|
||||||
buffer[dotpos]='\0';
|
|
||||||
return(buffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char * tree_get_filename(int selected_item, void * data, char *buffer)
|
static char * tree_get_filename(int selected_item, void * data, char *buffer)
|
||||||
{
|
{
|
||||||
struct tree_context * local_tc=(struct tree_context *)data;
|
struct tree_context * local_tc=(struct tree_context *)data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue