mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 09:40:51 +01:00
Fix companion files for extensionless formats
This commit is contained in:
parent
056ee4fbd8
commit
962e32dbf4
@ -771,12 +771,23 @@ STREAMFILE * open_streamfile(STREAMFILE *streamFile, const char * pathname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
STREAMFILE * open_streamfile_by_ext(STREAMFILE *streamFile, const char * ext) {
|
STREAMFILE * open_streamfile_by_ext(STREAMFILE *streamFile, const char * ext) {
|
||||||
char filename_ext[PATH_LIMIT];
|
char filename[PATH_LIMIT];
|
||||||
|
int filename_len, fileext_len;
|
||||||
|
|
||||||
streamFile->get_name(streamFile,filename_ext,sizeof(filename_ext));
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||||
strcpy(filename_ext + strlen(filename_ext) - strlen(filename_extension(filename_ext)), ext);
|
|
||||||
|
|
||||||
return streamFile->open(streamFile,filename_ext,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
filename_len = strlen(filename);
|
||||||
|
fileext_len = strlen(filename_extension(filename));
|
||||||
|
|
||||||
|
if (fileext_len == 0) {/* extensionless */
|
||||||
|
strcat(filename,".");
|
||||||
|
strcat(filename,ext);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
strcpy(filename + filename_len - fileext_len, ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
STREAMFILE * open_streamfile_by_filename(STREAMFILE *streamFile, const char * name) {
|
STREAMFILE * open_streamfile_by_filename(STREAMFILE *streamFile, const char * name) {
|
||||||
|
Loading…
Reference in New Issue
Block a user