summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2004-10-20 07:15:43 +0000
committerpixel <pixel>2004-10-20 07:15:43 +0000
commit6d696354d196b71225a97116c729c8ad8d9dac61 (patch)
tree3ba94d9af2b1fd1fd83fd7267223955444b7b0ac /lib
parent551a53e1b9c0fb7699e4e44e273d9f57111a1c21 (diff)
Adding less dodgy readsector code.
Diffstat (limited to 'lib')
-rw-r--r--lib/cdutils.cpp31
1 files changed, 21 insertions, 10 deletions
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 <stdio.h>
#include <string.h>
@@ -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];
}