remove extension when loading ins from file

This commit is contained in:
tildearrow 2022-02-26 04:49:40 -05:00
parent 271b3fb0fe
commit 1a69794efe
1 changed files with 14 additions and 5 deletions

View File

@ -1151,15 +1151,24 @@ enum DivInsFormats {
DIV_INSFORMAT_BTI
};
bool DivEngine::addInstrumentFromFile(const char *path) {
bool DivEngine::addInstrumentFromFile(const char* path) {
warnings="";
const char* pathRedux=strrchr(path,DIR_SEPARATOR);
if (pathRedux==NULL) {
pathRedux="Instrument";
pathRedux=path;
} else {
pathRedux++;
}
String stripPath;
const char* pathReduxEnd=strrchr(pathRedux,'.');
if (pathReduxEnd==NULL) {
stripPath=pathRedux;
} else {
for (const char* i=pathRedux; pathRedux!=pathReduxEnd && (*i); i++) {
stripPath+=*i;
}
}
FILE* f=ps_fopen(path,"rb");
if (f==NULL) {
@ -1284,7 +1293,7 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
return false;
}
ins->name=pathRedux;
ins->name=stripPath;
if (version>=11) { // 1.0
try {
@ -1517,7 +1526,7 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
reader.seek(0,SEEK_SET);
ins->type=DIV_INS_FM;
ins->name=pathRedux;
ins->name=stripPath;
ins->fm.alg=reader.readC();
ins->fm.fb=reader.readC();
@ -1549,7 +1558,7 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
reader.seek(0,SEEK_SET);
ins->type=DIV_INS_FM;
ins->name=pathRedux;
ins->name=stripPath;
ins->fm.alg=reader.readC();
ins->fm.fb=reader.readC();