diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cdreader.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/lib/cdreader.cpp b/lib/cdreader.cpp index cdb2671..59c8127 100644 --- a/lib/cdreader.cpp +++ b/lib/cdreader.cpp @@ -14,32 +14,6 @@ #define _(x) x #endif -#ifdef __linux__ -#include <sys/ioctl.h> -#include <linux/cdrom.h> - -cdreader::cdreader(const String & no) throw (GeneralException) : - Handle(open(no.to_charp(), O_RDONLY)), n(no), sector(0) { - -#ifdef DEBUG - fprintf(stderr, "Opening file %s, cdreader at %p\n", no.to_charp(), this); -#endif - - if (GetHandle() < 0) { - throw IOGeneral(String(_("Error opening file ")) + no + _(" for reading: ") + strerror(errno)); - } - - struct stat s; - fstat(GetHandle(), &s); - - if (!S_ISBLK(s.st_mode)) { - throw GeneralException(no + " is not a block device."); - } -} - -cdreader::cdreader(const cdreader & i) : Handle(i), n(i.n) { -} - bool cdreader::CanWrite() { return 0; } @@ -94,6 +68,36 @@ ssize_t cdreader::read(void *buf, size_t count) throw (GeneralException) { return r; } +void cdreader::sectorseek(int sec) { + sector = sec; +} + +#ifdef __linux__ +#include <sys/ioctl.h> +#include <linux/cdrom.h> + +cdreader::cdreader(const String & no) throw (GeneralException) : + Handle(open(no.to_charp(), O_RDONLY)), n(no), sector(0) { + +#ifdef DEBUG + fprintf(stderr, "Opening file %s, cdreader at %p\n", no.to_charp(), this); +#endif + + if (GetHandle() < 0) { + throw IOGeneral(String(_("Error opening file ")) + no + _(" for reading: ") + strerror(errno)); + } + + struct stat s; + fstat(GetHandle(), &s); + + if (!S_ISBLK(s.st_mode)) { + throw GeneralException(no + " is not a block device."); + } +} + +cdreader::cdreader(const cdreader & i) : Handle(i), n(i.n) { +} + void cdreader::getsector(void *buf, int sec) throw (GeneralException) { struct cdrom_msf * msf = (struct cdrom_msf *) buf; if (sec >= 0) @@ -117,8 +121,4 @@ void cdreader::getsector(void *buf, int sec) throw (GeneralException) { sector++; } -void cdreader::sectorseek(int sec) { - sector = sec; -} - #endif |