diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-06-29 07:45:33 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-06-29 07:45:33 +0000 |
commit | 1ed2e514da489527606aafe71ca03258fd6bde06 (patch) | |
tree | d654d120f8eaa1a962c6e26177361bcb7bac0bf0 /rbutil/rbutilqt/utils.cpp | |
parent | a3e63cf044a18593b8b1bc242c13b3e4a51f9888 (diff) | |
download | rockbox-1ed2e514da489527606aafe71ca03258fd6bde06.tar.gz 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/utils.cpp')
-rw-r--r-- | rbutil/rbutilqt/utils.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
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 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include "utils.h" | 20 | #include "utils.h" |
21 | #ifdef UNICODE | ||
22 | #define _UNICODE | ||
23 | #endif | ||
21 | 24 | ||
22 | #include <QtCore> | 25 | #include <QtCore> |
23 | #include <QDebug> | 26 | #include <QDebug> |
24 | #include <cstdlib> | 27 | #include <cstdlib> |
25 | #include <stdio.h> | 28 | #include <stdio.h> |
26 | 29 | ||
30 | #if defined(Q_OS_WIN32) | ||
31 | #include <windows.h> | ||
32 | #include <tchar.h> | ||
33 | #include <winioctl.h> | ||
34 | #endif | ||
35 | |||
27 | // recursive function to delete a dir with files | 36 | // recursive function to delete a dir with files |
28 | bool recRmdir( const QString &dirName ) | 37 | bool recRmdir( const QString &dirName ) |
29 | { | 38 | { |
@@ -90,4 +99,41 @@ QString resolvePathCase(QString path) | |||
90 | return realpath; | 99 | return realpath; |
91 | } | 100 | } |
92 | 101 | ||
102 | #if defined(Q_OS_WIN32) | ||
103 | QString getMountpointByDevice(int drive) | ||
104 | { | ||
105 | QString result; | ||
106 | for(int letter = 'A'; letter <= 'Z'; letter++) { | ||
107 | DWORD written; | ||
108 | HANDLE h; | ||
109 | TCHAR uncpath[MAX_PATH]; | ||
110 | UCHAR buffer[0x400]; | ||
111 | PVOLUME_DISK_EXTENTS extents = (PVOLUME_DISK_EXTENTS)buffer; | ||
112 | |||
113 | _stprintf(uncpath, _TEXT("\\\\.\\%c:"), letter); | ||
114 | h = CreateFile(uncpath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, | ||
115 | NULL, OPEN_EXISTING, 0, NULL); | ||
116 | if(h == INVALID_HANDLE_VALUE) { | ||
117 | qDebug() << "error getting extents for" << uncpath; | ||
118 | continue; | ||
119 | } | ||
120 | // get the extents | ||
121 | if(DeviceIoControl(h, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, | ||
122 | NULL, 0, extents, sizeof(buffer), &written, NULL)) { | ||
123 | for(int a = 0; a < extents->NumberOfDiskExtents; a++) { | ||
124 | qDebug() << "Disk:" << extents->Extents[a].DiskNumber; | ||
125 | if(extents->Extents[a].DiskNumber == drive) { | ||
126 | result = letter; | ||
127 | qDebug("found: %c", letter); | ||
128 | break; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | } | ||
133 | |||
134 | } | ||
135 | return result; | ||
136 | |||
137 | } | ||
138 | #endif | ||
93 | 139 | ||