Fail initializing the CD-FLAC codec if the hunk size is not CD-compatible.

Centralize detection of existing output files. Add detection (require --force)
for extracted files as well. Move checks outside of try/catch so that the
files are not subsequently deleted.
This commit is contained in:
Aaron Giles 2012-02-17 18:24:30 +00:00
parent 9e8ea7466f
commit 397de27f0c
2 changed files with 528 additions and 501 deletions

View File

@ -1248,6 +1248,10 @@ chd_cd_flac_compressor::chd_cd_flac_compressor(chd_file &chd, bool lossy)
: chd_compressor(chd, lossy),
m_buffer(chd.hunk_bytes())
{
// make sure the CHD's hunk size is an even multiple of the frame size
if (chd.hunk_bytes() % CD_FRAME_SIZE != 0)
throw CHDERR_CODEC_ERROR;
// determine whether we want native or swapped samples
UINT16 native_endian = 0;
*reinterpret_cast<UINT8 *>(&native_endian) = 1;
@ -1342,6 +1346,10 @@ chd_cd_flac_decompressor::chd_cd_flac_decompressor(chd_file &chd, bool lossy)
: chd_decompressor(chd, lossy),
m_buffer(chd.hunk_bytes())
{
// make sure the CHD's hunk size is an even multiple of the frame size
if (chd.hunk_bytes() % CD_FRAME_SIZE != 0)
throw CHDERR_CODEC_ERROR;
// determine whether we want native or swapped samples
UINT16 native_endian = 0;
*reinterpret_cast<UINT8 *>(&native_endian) = 1;

File diff suppressed because it is too large Load Diff