summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2008-06-29 07:45:33 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2008-06-29 07:45:33 +0000
commit1ed2e514da489527606aafe71ca03258fd6bde06 (patch)
treed654d120f8eaa1a962c6e26177361bcb7bac0bf0 /rbutil/rbutilqt
parenta3e63cf044a18593b8b1bc242c13b3e4a51f9888 (diff)
downloadrockbox-1ed2e514da489527606aafe71ca03258fd6bde06.tar.gz
rockbox-1ed2e514da489527606aafe71ca03258fd6bde06.tar.bz2
rockbox-1ed2e514da489527606aafe71ca03258fd6bde06.zip
Add W32 mountpoint resolving based on the disc number figured by ipodpatcher / sansapatcher.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17868 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/autodetection.cpp8
-rw-r--r--rbutil/rbutilqt/utils.cpp46
-rw-r--r--rbutil/rbutilqt/utils.h4
3 files changed, 58 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/autodetection.cpp b/rbutil/rbutilqt/autodetection.cpp
index c356cc6307..431cb0251e 100644
--- a/rbutil/rbutilqt/autodetection.cpp
+++ b/rbutil/rbutilqt/autodetection.cpp
@@ -160,6 +160,9 @@ bool Autodetection::detect()
#if !defined(Q_OS_WIN32)
m_mountpoint = resolveMountPoint(ipod.diskname);
#endif
+#if defined(Q_OS_WIN32)
+ m_mountpoint = getMountpointByDevice(ipod.diskname);
+#endif
return true;
}
@@ -169,7 +172,12 @@ bool Autodetection::detect()
if(n == 1) {
qDebug() << "Sansa found:" << sansa.targetname << "at" << sansa.diskname;
m_device = QString("sansa%1").arg(sansa.targetname);
+#if !defined(Q_OS_WIN32)
m_mountpoint = resolveMountPoint(sansa.diskname);
+#endif
+#if defined(Q_OS_WIN32)
+ m_mountpoint = getMountpointByDevice(sansa.diskname);
+#endif
return true;
}
diff --git a/rbutil/rbutilqt/utils.cpp b/rbutil/rbutilqt/utils.cpp
index 236f28babd..3e3a5912b2 100644
--- a/rbutil/rbutilqt/utils.cpp
+++ b/rbutil/rbutilqt/utils.cpp
@@ -18,12 +18,21 @@
****************************************************************************/
#include "utils.h"
+#ifdef UNICODE
+#define _UNICODE
+#endif
#include <QtCore>
#include <QDebug>
#include <cstdlib>
#include <stdio.h>
+#if defined(Q_OS_WIN32)
+#include <windows.h>
+#include <tchar.h>
+#include <winioctl.h>
+#endif
+
// recursive function to delete a dir with files
bool recRmdir( const QString &dirName )
{
@@ -90,4 +99,41 @@ QString resolvePathCase(QString path)
return realpath;
}
+#if defined(Q_OS_WIN32)
+QString getMountpointByDevice(int drive)
+{
+ QString result;
+ for(int letter = 'A'; letter <= 'Z'; letter++) {
+ DWORD written;
+ HANDLE h;
+ TCHAR uncpath[MAX_PATH];
+ UCHAR buffer[0x400];
+ PVOLUME_DISK_EXTENTS extents = (PVOLUME_DISK_EXTENTS)buffer;
+
+ _stprintf(uncpath, _TEXT("\\\\.\\%c:"), letter);
+ h = CreateFile(uncpath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, 0, NULL);
+ if(h == INVALID_HANDLE_VALUE) {
+ qDebug() << "error getting extents for" << uncpath;
+ continue;
+ }
+ // get the extents
+ if(DeviceIoControl(h, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
+ NULL, 0, extents, sizeof(buffer), &written, NULL)) {
+ for(int a = 0; a < extents->NumberOfDiskExtents; a++) {
+ qDebug() << "Disk:" << extents->Extents[a].DiskNumber;
+ if(extents->Extents[a].DiskNumber == drive) {
+ result = letter;
+ qDebug("found: %c", letter);
+ break;
+ }
+ }
+
+ }
+
+ }
+ return result;
+
+}
+#endif
diff --git a/rbutil/rbutilqt/utils.h b/rbutil/rbutilqt/utils.h
index 19cdca92c9..904f5903bc 100644
--- a/rbutil/rbutilqt/utils.h
+++ b/rbutil/rbutilqt/utils.h
@@ -29,5 +29,9 @@
bool recRmdir( const QString &dirName );
QString resolvePathCase(QString path);
+#if defined(Q_OS_WIN32)
+QString getMountpointByDevice(int drive);
+#endif
+
#endif