Add TXTH sub-extension (.sub.ext.txth) to simplify extra config

This commit is contained in:
bnnm 2019-01-12 01:00:07 +01:00
parent 699e1092a0
commit 07abb4692d
2 changed files with 22 additions and 0 deletions

View File

@ -9,6 +9,10 @@ When an unsupported file is loaded (for instance "bgm01.snd"), vgmstream tries t
If found and parsed correctly (the TXTH may be rejected if incorrect commands are found) vgmstream will try to play the file as described. Extension must be accepted/added to vgmstream (plugins like foobar2000 only load extensions from a whitelist in formats.c), or one could rename to any supported extension (like .vgmstream), or leave the file extensionless.
You can also use ".(sub).(ext).txth" (if the file is "filename.sub.ext"), to allow mixing slightly different files in the same folder. The "sub" part doesn't need to be an extension, for example:
- 001.1ch.str, 001.1ch.str may use .1ch.txth
- 003.2ch.str, 003.2ch.str may use .2ch.txth
- etc
## Example of a TXTH file
For an unsupported bgm01.vag this would be a simple TXTH for it:

View File

@ -477,8 +477,10 @@ fail:
static STREAMFILE * open_txth(STREAMFILE * streamFile) {
char basename[PATH_LIMIT];
char filename[PATH_LIMIT];
char fileext[PATH_LIMIT];
const char *subext;
STREAMFILE * streamText;
/* try "(path/)(name.ext).txth" */
@ -487,6 +489,22 @@ static STREAMFILE * open_txth(STREAMFILE * streamFile) {
streamText = open_streamfile(streamFile,filename);
if (streamText) return streamText;
/* try "(path/)(.sub.ext).txth" */
get_streamfile_basename(streamFile,basename,PATH_LIMIT);
subext = filename_extension(basename);
if (subext != NULL) {
get_streamfile_path(streamFile,filename,PATH_LIMIT);
get_streamfile_ext(streamFile,fileext,PATH_LIMIT);
strcat(filename,".");
strcat(filename, subext);
strcat(filename,".");
strcat(filename, fileext);
strcat(filename, ".txth");
streamText = open_streamfile(streamFile,filename);
if (streamText) return streamText;
}
/* try "(path/)(.ext).txth" */
get_streamfile_path(streamFile,filename,PATH_LIMIT);
get_streamfile_ext(streamFile,fileext,PATH_LIMIT);