add instrument read error messages

This commit is contained in:
tildearrow 2022-01-29 04:25:55 -05:00
parent 28a0f8775f
commit 17ca6402d3

View file

@ -4299,30 +4299,36 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
warnings=""; warnings="";
FILE* f=ps_fopen(path,"rb"); FILE* f=ps_fopen(path,"rb");
if (f==NULL) { if (f==NULL) {
lastError=strerror(errno);
return false; return false;
} }
unsigned char* buf; unsigned char* buf;
ssize_t len; ssize_t len;
if (fseek(f,0,SEEK_END)!=0) { if (fseek(f,0,SEEK_END)!=0) {
lastError=strerror(errno);
fclose(f); fclose(f);
return false; return false;
} }
len=ftell(f); len=ftell(f);
if (len<0) { if (len<0) {
lastError=strerror(errno);
fclose(f); fclose(f);
return false; return false;
} }
if (len==0) { if (len==0) {
lastError=strerror(errno);
fclose(f); fclose(f);
return false; return false;
} }
if (fseek(f,0,SEEK_SET)!=0) { if (fseek(f,0,SEEK_SET)!=0) {
lastError=strerror(errno);
fclose(f); fclose(f);
return false; return false;
} }
buf=new unsigned char[len]; buf=new unsigned char[len];
if (fread(buf,1,len,f)!=(size_t)len) { if (fread(buf,1,len,f)!=(size_t)len) {
logW("did not read entire instrument file buffer!\n"); logW("did not read entire instrument file buffer!\n");
lastError="did not read entire instrument file!";
delete[] buf; delete[] buf;
return false; return false;
} }