Check for ID3v2 tag when using flac -t

This commit is contained in:
Martijn van Beurden 2022-11-04 17:03:48 +01:00 committed by GitHub
parent 9ca1e062c2
commit 3975b3e6a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -328,6 +328,23 @@ FLAC__bool DecoderSession_init_decoder(DecoderSession *decoder_session, const ch
}
}
}
else if(decoder_session->test_only && strcmp(infilename, "-") != 0) {
/* When testing, we can be a little more pedantic, as long
* as we can seek properly */
FLAC__byte buffer[3];
FILE * f = flac_fopen(infilename, "rb");
if(fread(buffer, 1, 3, f) < 3) {
flac__utils_printf(stderr, 1, "%s: ERROR checking for ID3v2 tag\n", decoder_session->inbasefilename);
return false;
}
if(memcmp(buffer, "ID3", 3) == 0){
flac__utils_printf(stderr, 1, "%s: WARNING, ID3v2 tag found. This is non-standard and strongly discouraged\n", decoder_session->inbasefilename);
if(decoder_session->treat_warnings_as_errors) {
return false;
}
}
}
decoder_session->decoder = FLAC__stream_decoder_new();