From 6d696354d196b71225a97116c729c8ad8d9dac61 Mon Sep 17 00:00:00 2001 From: pixel Date: Wed, 20 Oct 2004 07:15:43 +0000 Subject: Adding less dodgy readsector code. --- lib/cdutils.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/cdutils.cpp b/lib/cdutils.cpp index 2d9263b..953b76e 100644 --- a/lib/cdutils.cpp +++ b/lib/cdutils.cpp @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: cdutils.cpp,v 1.31 2004-10-19 15:58:41 pixel Exp $ */ +/* $Id: cdutils.cpp,v 1.32 2004-10-20 07:15:43 pixel Exp $ */ #include #include @@ -199,17 +199,28 @@ void cdutils::sector_seek(long sector) { } long cdutils::read_sector(Byte * buffer, int type, int number) { - if (number >= 0) { - sector_seek(number); - } + try { + if (number >= 0) { + sector_seek(number); + } - if (type == GUESS) { - type = guess_type(); - } + if (type == GUESS) { + type = guess_type(); + } - f_iso_r->seek(sec_offsts[type], SEEK_CUR); - f_iso_r->read(buffer, sec_sizes[type]); - f_iso_r->seek(2352 - sec_offsts[type] - sec_sizes[type], SEEK_CUR); + f_iso_r->seek(sec_offsts[type], SEEK_CUR); + f_iso_r->read(buffer, sec_sizes[type]); + f_iso_r->seek(2352 - sec_offsts[type] - sec_sizes[type], SEEK_CUR); + } catch (GeneralException e) { + if (number >= 0) + printm(M_ERROR, "Trouble reading sector %i: %s\n", number, e.GetMsg()); + else + printm(M_ERROR, "Trouble reading sector: %s\n", e.GetMsg()); + + if (type != GUESS) + memset(buffer, 0, sec_sizes[type]); + return 0; + } return sec_sizes[type]; } -- cgit v1.2.3