patch: Handle gtk-gnutella's stupid filenames
Mike Schiraldi <[email protected]>
| Newsgroups | gmane.comp.multimedia.xmms.devel |
|---|---|
| Message-ID | <[email protected]> |
gtk-gnutella has an annoying "feature" in the way it names files. When you are first downloading "foo.mp3", it will be properly named "foo.mp3" on your machine. If you shut down before getting the whole file, it will properly still be named "foo.mp3". Here's the annoying part: if the download completes, it will be renamed to "foo.mp3.OK". And if you're getting it from multiple sources, you could get names like "foo.mp3.01.OK" or "foo.mp3.OK.01". The following patch will allow xmms to play these files.
xmms-gtk-gnut.patch
(text/plain, 1.2 KB)
--- mpg123.c.old Sun Jul 20 17:53:21 2003
+++ mpg123.c Sun Jul 20 17:53:22 2003
@@ -391,6 +391,7 @@
static int is_our_file(char *filename)
{
+ char *tmp;
char *ext;
guint16 wavid;
@@ -411,11 +412,24 @@
}
if(mpg123_cfg.detect_by_content)
return (mpg123_detect_by_content(filename));
- ext = strrchr(filename, '.');
+
+ tmp = strdup (filename);
+ while(1) {
+ ext = strrchr(tmp, '.');
+ if (
+ (strlen(ext) == 3 &&
+ ext[1] >= '0' && ext[1] <= '9' &&
+ ext[2] >= '0' && ext[2] <= '9') ||
+ !strncmp(ext, ".OK", 3)) {
+ ext[0] = 0;
+ } else break;
+ }
+
if (ext)
{
if (!strncasecmp(ext, ".mp2", 4) || !strncasecmp(ext, ".mp3", 4))
{
+ free(tmp);
return TRUE;
}
if (!strncasecmp(ext, ".wav", 4))
@@ -423,10 +437,12 @@
wavid = read_wav_id(filename);
if (wavid == 85 || wavid == 80)
{ /* Microsoft says 80, files say 85... */
+ free(tmp);
return TRUE;
}
}
}
+ free(tmp);
return FALSE;
}