summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2008-01-18 10:02:03 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2008-01-18 10:02:03 +0000
commit536b5a0482454d3e3104f2a77a29d37319bc845c (patch)
tree9c49613ba5723a0d615c4ad41f84e641dfd14fda
parent905d80619c3f7dec778fd29fa9ec77dda2ac8bcf (diff)
downloadrockbox-536b5a0482454d3e3104f2a77a29d37319bc845c.zip
rockbox-536b5a0482454d3e3104f2a77a29d37319bc845c.tar.gz
rockbox-536b5a0482454d3e3104f2a77a29d37319bc845c.tar.bz2
rockbox-536b5a0482454d3e3104f2a77a29d37319bc845c.tar.xz
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
-rw-r--r--apps/misc.c19
-rw-r--r--apps/misc.h5
-rw-r--r--apps/recorder/albumart.c30
-rw-r--r--apps/tree.c19
4 files changed, 25 insertions, 48 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 85ab396..a851695 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -1120,3 +1120,22 @@ bool dir_exists(const char *path)
closedir(d);
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;
+}
diff --git a/apps/misc.h b/apps/misc.h
index 590ccf0..99eadc4 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -118,5 +118,10 @@ char* strrsplt(char* str, int c);
bool file_exists(const char *file);
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 */
diff --git a/apps/recorder/albumart.c b/apps/recorder/albumart.c
index 6761cfc..0e45d9a 100644
--- a/apps/recorder/albumart.c
+++ b/apps/recorder/albumart.c
@@ -62,34 +62,6 @@ static char* strip_filename(char* buf, int buf_size, const char* fullpath)
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.
* Double quotes are replaced with single quotes, other unsupported chars
* 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;
/* 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, ".bmp");
found = file_exists(path);
diff --git a/apps/tree.c b/apps/tree.c
index 09c70f0..6ee242b 100644
--- a/apps/tree.c
+++ b/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 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)
{
struct tree_context * local_tc=(struct tree_context *)data;