mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 15:54:05 +01:00
Fix extensionless files inside folders with dots in winamp/CLI
This commit is contained in:
parent
cb93647cdd
commit
c720d6ce37
30
src/util.c
30
src/util.c
@ -6,22 +6,26 @@ const char * filename_extension(const char * pathname) {
|
||||
const char * filename;
|
||||
const char * extension;
|
||||
|
||||
/* get basename + extension */
|
||||
filename = pathname;
|
||||
#if 0
|
||||
//must detect empty extensions in folders with . in the name; not too important and DIR_SEPARATOR could improved
|
||||
filename = strrchr(pathname, DIR_SEPARATOR);
|
||||
if (filename == NULL)
|
||||
filename = pathname; /* pathname has no separators (single filename) */
|
||||
else
|
||||
filename++; /* skip the separator */
|
||||
#endif
|
||||
/* favor strrchr (optimized/aligned) rather than homemade loops */
|
||||
|
||||
/* find possible separator first to avoid misdetecting folders with dots + extensionless files
|
||||
* (allow both slashes as plugin could pass normalized '/') */
|
||||
filename = strrchr(pathname, '/');
|
||||
if (filename != NULL)
|
||||
filename++; /* skip separator */
|
||||
else {
|
||||
filename = strrchr(pathname, '\\');
|
||||
if (filename != NULL)
|
||||
filename++; /* skip separator */
|
||||
else
|
||||
filename = pathname; /* pathname has no separators (single filename) */
|
||||
}
|
||||
|
||||
extension = strrchr(filename,'.');
|
||||
if (extension==NULL)
|
||||
extension = filename+strlen(filename); /* point to null, i.e. an empty string for the extension */
|
||||
if (extension != NULL)
|
||||
extension++; /* skip dot */
|
||||
else
|
||||
extension++; /* skip the dot */
|
||||
extension = filename + strlen(filename); /* point to null (empty "" string for extensionless files) */
|
||||
|
||||
return extension;
|
||||
}
|
||||
|
@ -994,21 +994,26 @@ int winamp_IsOurFile(const in_char *fn) {
|
||||
const in_char *filename;
|
||||
const in_char *extension;
|
||||
|
||||
/* get basename + extension */
|
||||
filename = fn;
|
||||
#if 0
|
||||
//must detect empty extensions in folders with . in the name; doesn't work ok?
|
||||
/* favor strrchr (optimized/aligned) rather than homemade loops */
|
||||
|
||||
/* find possible separator first to avoid misdetecting folders with dots + extensionless files
|
||||
* (allow both slashes as plugin could pass normalized '/') */
|
||||
filename = wa_strrchr(fn, wa_L('\\'));
|
||||
if (filename == NULL)
|
||||
filename = fn;
|
||||
if (filename != NULL)
|
||||
filename++; /* skip separator */
|
||||
else {
|
||||
filename = wa_strrchr(fn, wa_L('/'));
|
||||
if (filename != NULL)
|
||||
filename++; /* skip separator */
|
||||
else
|
||||
filename = fn; /* pathname has no separators (single filename) */
|
||||
}
|
||||
|
||||
extension = wa_strrchr(filename,'.');
|
||||
if (extension != NULL)
|
||||
extension++; /* skip dot */
|
||||
else
|
||||
filename++;
|
||||
#endif
|
||||
extension = wa_strrchr(filename, wa_L('.'));
|
||||
if (extension == NULL)
|
||||
return 1; /* extensionless, try to play it */
|
||||
else
|
||||
extension++;
|
||||
|
||||
/* returning 0 here means it only accepts the extensions in working_extension_list */
|
||||
/* it's possible to ignore the list and manually accept extensions, like foobar's g_is_our_path */
|
||||
|
Loading…
x
Reference in New Issue
Block a user