summaryrefslogtreecommitdiff
path: root/lib/cdabstract.cpp
diff options
context:
space:
mode:
authorpixel <pixel>2003-12-11 16:53:42 +0000
committerpixel <pixel>2003-12-11 16:53:42 +0000
commitbacf50104daa09cd90f8dc36c06a6982d91000af (patch)
tree863ace96383ca62afc109bfca550dc64e59ce99d /lib/cdabstract.cpp
parent5695a4b1e91154f8b9bae6d62eb9313b973fc6bd (diff)
Linux ports
Diffstat (limited to 'lib/cdabstract.cpp')
-rw-r--r--lib/cdabstract.cpp144
1 files changed, 72 insertions, 72 deletions
diff --git a/lib/cdabstract.cpp b/lib/cdabstract.cpp
index 103be1a..ff438c4 100644
--- a/lib/cdabstract.cpp
+++ b/lib/cdabstract.cpp
@@ -17,17 +17,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: cdabstract.cpp,v 1.6 2003-12-04 01:55:15 pixel Exp $ */
+/* $Id: cdabstract.cpp,v 1.7 2003-12-11 16:53:43 pixel Exp $ */
#include "cdabstract.h"
#include "Input.h"
#include "cdreader.h"
#ifdef __linux__
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <linux/cdrom.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <linux/cdrom.h>
#endif
#if defined (_MSC_VER) || defined (__MINGW32__)
@@ -47,13 +47,13 @@ bool cdabstract::canprobe() {
return true;
#endif
#ifdef _WIN32
- OSVERSIONINFO ov;
- memset(&ov, 0, sizeof(OSVERSIONINFO));
- ov.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-
- GetVersionEx(&ov);
-
- return ((ov.dwPlatformId == VER_PLATFORM_WIN32_NT) && (ov.dwMajorVersion > 4));
+ OSVERSIONINFO ov;
+ memset(&ov, 0, sizeof(OSVERSIONINFO));
+ ov.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ GetVersionEx(&ov);
+
+ return ((ov.dwPlatformId == VER_PLATFORM_WIN32_NT) && (ov.dwMajorVersion > 4));
#endif
return false;
}
@@ -94,66 +94,66 @@ std::vector<String> cdabstract::probe() throw (GeneralException) {
}
#ifdef _WIN32
-HANDLE cdabstract::OpenIOCTLFile(char cLetter) {
- HANDLE hF;
- char szFName[16];
- OSVERSIONINFO ov;
- DWORD dwFlags;
- DWORD dwIOCTLAttr = 0;
-
- memset(&ov, 0, sizeof(OSVERSIONINFO));
- ov.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&ov);
-
- if((ov.dwPlatformId == VER_PLATFORM_WIN32_NT) && (ov.dwMajorVersion > 4))
- dwFlags = GENERIC_READ | GENERIC_WRITE; // add gen write on W2k/XP
- else dwFlags = GENERIC_READ;
-
- sprintf(szFName, "\\\\.\\%c:", cLetter);
-
- hF = CreateFile(szFName, dwFlags, FILE_SHARE_READ, // open drive
- NULL, OPEN_EXISTING, dwIOCTLAttr, NULL);
-
- if (hF == INVALID_HANDLE_VALUE) { // mmm... no success?
- dwFlags ^= GENERIC_WRITE; // -> try write toggle
- hF = CreateFile(szFName, dwFlags, FILE_SHARE_READ, // -> open drive again
- NULL, OPEN_EXISTING, dwIOCTLAttr, NULL);
- if (hF == INVALID_HANDLE_VALUE)
- return NULL;
- }
- return hF;
-}
-
-typedef struct {
- ULONG Length;
- UCHAR PortNumber;
- UCHAR PathId;
- UCHAR TargetId;
- UCHAR Lun;
-} SCSI_ADDRESS, *PSCSI_ADDRESS;
-
-void cdabstract::GetIOCTLAdapter(HANDLE hF, int * iDA, int * iDT, int * iDL) {
- char szBuf[1024];
- PSCSI_ADDRESS pSA;
- DWORD dwRet;
-
- *iDA = *iDT = *iDL = -1;
-
- if (hF == NULL)
- return;
-
- memset(szBuf,0,1024);
-
- pSA = (PSCSI_ADDRESS)szBuf;
- pSA->Length = sizeof(SCSI_ADDRESS);
-
- if (!DeviceIoControl(hF, IOCTL_SCSI_GET_ADDRESS, NULL, 0, pSA,
- sizeof(SCSI_ADDRESS), &dwRet, NULL))
- return;
-
- *iDA = pSA->PortNumber;
- *iDT = pSA->TargetId;
- *iDL = pSA->Lun;
+HANDLE cdabstract::OpenIOCTLFile(char cLetter) {
+ HANDLE hF;
+ char szFName[16];
+ OSVERSIONINFO ov;
+ DWORD dwFlags;
+ DWORD dwIOCTLAttr = 0;
+
+ memset(&ov, 0, sizeof(OSVERSIONINFO));
+ ov.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&ov);
+
+ if((ov.dwPlatformId == VER_PLATFORM_WIN32_NT) && (ov.dwMajorVersion > 4))
+ dwFlags = GENERIC_READ | GENERIC_WRITE; // add gen write on W2k/XP
+ else dwFlags = GENERIC_READ;
+
+ sprintf(szFName, "\\\\.\\%c:", cLetter);
+
+ hF = CreateFile(szFName, dwFlags, FILE_SHARE_READ, // open drive
+ NULL, OPEN_EXISTING, dwIOCTLAttr, NULL);
+
+ if (hF == INVALID_HANDLE_VALUE) { // mmm... no success?
+ dwFlags ^= GENERIC_WRITE; // -> try write toggle
+ hF = CreateFile(szFName, dwFlags, FILE_SHARE_READ, // -> open drive again
+ NULL, OPEN_EXISTING, dwIOCTLAttr, NULL);
+ if (hF == INVALID_HANDLE_VALUE)
+ return NULL;
+ }
+ return hF;
+}
+
+typedef struct {
+ ULONG Length;
+ UCHAR PortNumber;
+ UCHAR PathId;
+ UCHAR TargetId;
+ UCHAR Lun;
+} SCSI_ADDRESS, *PSCSI_ADDRESS;
+
+void cdabstract::GetIOCTLAdapter(HANDLE hF, int * iDA, int * iDT, int * iDL) {
+ char szBuf[1024];
+ PSCSI_ADDRESS pSA;
+ DWORD dwRet;
+
+ *iDA = *iDT = *iDL = -1;
+
+ if (hF == NULL)
+ return;
+
+ memset(szBuf,0,1024);
+
+ pSA = (PSCSI_ADDRESS)szBuf;
+ pSA->Length = sizeof(SCSI_ADDRESS);
+
+ if (!DeviceIoControl(hF, IOCTL_SCSI_GET_ADDRESS, NULL, 0, pSA,
+ sizeof(SCSI_ADDRESS), &dwRet, NULL))
+ return;
+
+ *iDA = pSA->PortNumber;
+ *iDT = pSA->TargetId;
+ *iDL = pSA->Lun;
}
#endif