mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
winutil compiles again
This commit is contained in:
parent
8a76c16d55
commit
65e78bf1f1
20
setup.py
20
setup.py
@ -59,6 +59,16 @@ if __name__ == '__main__':
|
||||
'calibre_postinstall = calibre.linux:post_install')
|
||||
optional = []
|
||||
|
||||
if iswindows:
|
||||
optional.append(Extension('calibre.plugins.winutil',
|
||||
sources=['src/calibre/utils/windows/winutil.c'],
|
||||
libraries=['shell32', 'setupapi'],
|
||||
include_dirs=os.environ.get('INCLUDE',
|
||||
'C:/WinDDK/6001.18001/inc/api/;'
|
||||
'C:/WinDDK/6001.18001/inc/crt/').split(';'),
|
||||
extra_compile_args=['/X']
|
||||
))
|
||||
|
||||
|
||||
podofo_inc = '/usr/include/podofo' if islinux else \
|
||||
'C:\\podofo\\include\\podofo' if iswindows else \
|
||||
@ -83,6 +93,7 @@ if __name__ == '__main__':
|
||||
r'C:\cygwin\home\kovid\fontconfig\lib' if iswindows else \
|
||||
'/Users/kovid/fontconfig/lib'
|
||||
|
||||
|
||||
ext_modules = optional + [
|
||||
|
||||
Extension('calibre.plugins.fontconfig',
|
||||
@ -113,15 +124,6 @@ if __name__ == '__main__':
|
||||
['src/calibre/gui2/pictureflow/pictureflow.sip']
|
||||
)
|
||||
]
|
||||
if iswindows:
|
||||
ext_modules.append(Extension('calibre.plugins.winutil',
|
||||
sources=['src/calibre/utils/windows/winutil.c'],
|
||||
libraries=['shell32', 'setupapi'],
|
||||
include_dirs=os.environ.get('INCLUDE',
|
||||
'C:/WinDDK/6001.18001/inc/api/;'
|
||||
'C:/WinDDK/6001.18001/inc/crt/').split(';'),
|
||||
extra_compile_args=['/X']
|
||||
))
|
||||
if isosx:
|
||||
ext_modules.append(Extension('calibre.plugins.usbobserver',
|
||||
sources=['src/calibre/devices/usbobserver/usbobserver.c'],
|
||||
|
@ -308,7 +308,7 @@ get_all_removable_disks(struct tagDrives *g_drives)
|
||||
|
||||
static DEVINST
|
||||
GetDrivesDevInstByDeviceNumber(long DeviceNumber,
|
||||
UINT DriveType, char* szDosDeviceName)
|
||||
UINT DriveType, LPWSTR szDosDeviceName)
|
||||
{
|
||||
GUID *guid;
|
||||
HDEVINFO hDevInfo;
|
||||
@ -319,8 +319,12 @@ GetDrivesDevInstByDeviceNumber(long DeviceNumber,
|
||||
long res;
|
||||
HANDLE hDrive;
|
||||
STORAGE_DEVICE_NUMBER sdn;
|
||||
SP_DEVICE_INTERFACE_DATA spdid;
|
||||
SP_DEVINFO_DATA spdd;
|
||||
DWORD dwSize;
|
||||
|
||||
IsFloppy = (strstr(szDosDeviceName, "\\Floppy") != NULL); // is there a better way?
|
||||
|
||||
IsFloppy = (wcsstr(szDosDeviceName, L"\\Floppy") != NULL); // is there a better way?
|
||||
|
||||
switch (DriveType) {
|
||||
case DRIVE_REMOVABLE:
|
||||
@ -357,12 +361,7 @@ GetDrivesDevInstByDeviceNumber(long DeviceNumber,
|
||||
bRet = FALSE;
|
||||
|
||||
|
||||
pspdidd =
|
||||
(PSP_DEVICE_INTERFACE_DETAIL_DATA)Buf;
|
||||
SP_DEVICE_INTERFACE_DATA spdid;
|
||||
SP_DEVINFO_DATA spdd;
|
||||
DWORD dwSize;
|
||||
|
||||
pspdidd = (PSP_DEVICE_INTERFACE_DETAIL_DATA)Buf;
|
||||
spdid.cbSize = sizeof(spdid);
|
||||
|
||||
while ( TRUE ) {
|
||||
@ -420,8 +419,11 @@ GetDrivesDevInstByDeviceNumber(long DeviceNumber,
|
||||
|
||||
|
||||
static BOOL
|
||||
eject_drive_letter(char DriveLetter) {
|
||||
char szRootPath[4], szDevicePath[3], szVolumeAccessPath[7], szDosDeviceName[MAX_PATH];
|
||||
eject_drive_letter(WCHAR DriveLetter) {
|
||||
LPWSTR szRootPath = L"X:\\",
|
||||
szDevicePath = L"X:",
|
||||
szVolumeAccessPath = L"\\\\.\\X:";
|
||||
WCHAR szDosDeviceName[MAX_PATH];
|
||||
long DeviceNumber, res, tries;
|
||||
HANDLE hVolume;
|
||||
STORAGE_DEVICE_NUMBER sdn;
|
||||
@ -429,17 +431,15 @@ eject_drive_letter(char DriveLetter) {
|
||||
DEVINST DevInst;
|
||||
ULONG Status;
|
||||
ULONG ProblemNumber;
|
||||
UINT DriveType;
|
||||
PNP_VETO_TYPE VetoType;
|
||||
WCHAR VetoNameW[MAX_PATH];
|
||||
BOOL bSuccess;
|
||||
DEVINST DevInstParent;
|
||||
|
||||
szRootPath[0] = DriveLetter; szRootPath[1] = ':'; szRootPath[2] = '\\'; szRootPath[3] = (char)0;
|
||||
szDevicePath[0] = DriveLetter; szDevicePath[1] = ':'; szDevicePath[2] = (char)0;
|
||||
szVolumeAccessPath[0] = '\\'; szVolumeAccessPath[1] = '\\'; szVolumeAccessPath[2] = '.';
|
||||
szVolumeAccessPath[3] = '\\'; szVolumeAccessPath[4] = DriveLetter; szVolumeAccessPath[5] = ':';
|
||||
szVolumeAccessPath[6] = (char)0;
|
||||
|
||||
szRootPath[0] = DriveLetter;
|
||||
szDevicePath[0] = DriveLetter;
|
||||
szVolumeAccessPath[4] = DriveLetter;
|
||||
|
||||
DeviceNumber = -1;
|
||||
|
||||
@ -472,6 +472,8 @@ eject_drive_letter(char DriveLetter) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DriveType = GetDriveType(szRootPath);
|
||||
|
||||
DevInst = GetDrivesDevInstByDeviceNumber(DeviceNumber,
|
||||
DriveType, szDosDeviceName);
|
||||
if (DevInst == 0) return FALSE;
|
||||
@ -479,7 +481,6 @@ eject_drive_letter(char DriveLetter) {
|
||||
DevInstParent = 0;
|
||||
Status = 0;
|
||||
ProblemNumber = 0;
|
||||
PNP_VETO_TYPE VetoType;
|
||||
bSuccess = FALSE;
|
||||
|
||||
res = CM_Get_Parent(&DevInstParent, DevInst, 0);
|
||||
@ -508,7 +509,7 @@ winutil_eject_drive(PyObject *self, PyObject *args) {
|
||||
|
||||
if (!PyArg_ParseTuple(args, "c", &DriveLetter)) return NULL;
|
||||
|
||||
if (!eject_drive_letter(DriveLetter)) return NULL;
|
||||
if (!eject_drive_letter((WCHAR)DriveLetter)) return NULL;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user