mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-13 14:21:11 +01:00
Add more info to WAV import errors
Print mismatched header contents and file size, which can provide more clues to users when debugging. (cherry picked from commit f5d256b118914817e2c7ac5c35421e2767fc1e79)
This commit is contained in:
parent
c88d8dd201
commit
6ebc813e48
@ -104,9 +104,10 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
|
|||||||
file->get_buffer((uint8_t *)&riff, 4); //RIFF
|
file->get_buffer((uint8_t *)&riff, 4); //RIFF
|
||||||
|
|
||||||
if (riff[0] != 'R' || riff[1] != 'I' || riff[2] != 'F' || riff[3] != 'F') {
|
if (riff[0] != 'R' || riff[1] != 'I' || riff[2] != 'F' || riff[3] != 'F') {
|
||||||
|
uint64_t length = file->get_len();
|
||||||
file->close();
|
file->close();
|
||||||
memdelete(file);
|
memdelete(file);
|
||||||
ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
|
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, vformat("Not a WAV file. File should start with 'RIFF', but found '%s', in file of size %d bytes", riff, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GET FILESIZE */
|
/* GET FILESIZE */
|
||||||
@ -114,14 +115,15 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
|
|||||||
|
|
||||||
/* CHECK WAVE */
|
/* CHECK WAVE */
|
||||||
|
|
||||||
char wave[4];
|
char wave[5];
|
||||||
|
wave[4] = 0;
|
||||||
file->get_buffer((uint8_t *)&wave, 4); //RIFF
|
file->get_buffer((uint8_t *)&wave, 4); //WAVE
|
||||||
|
|
||||||
if (wave[0] != 'W' || wave[1] != 'A' || wave[2] != 'V' || wave[3] != 'E') {
|
if (wave[0] != 'W' || wave[1] != 'A' || wave[2] != 'V' || wave[3] != 'E') {
|
||||||
|
uint64_t length = file->get_len();
|
||||||
file->close();
|
file->close();
|
||||||
memdelete(file);
|
memdelete(file);
|
||||||
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Not a WAV file (no WAVE RIFF header).");
|
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, vformat("Not a WAV file. Header should contain 'WAVE', but found '%s', in file of size %d bytes", wave, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let users override potential loop points from the WAV.
|
// Let users override potential loop points from the WAV.
|
||||||
|
Loading…
Reference in New Issue
Block a user