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')
|
'calibre_postinstall = calibre.linux:post_install')
|
||||||
optional = []
|
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 \
|
podofo_inc = '/usr/include/podofo' if islinux else \
|
||||||
'C:\\podofo\\include\\podofo' if iswindows 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 \
|
r'C:\cygwin\home\kovid\fontconfig\lib' if iswindows else \
|
||||||
'/Users/kovid/fontconfig/lib'
|
'/Users/kovid/fontconfig/lib'
|
||||||
|
|
||||||
|
|
||||||
ext_modules = optional + [
|
ext_modules = optional + [
|
||||||
|
|
||||||
Extension('calibre.plugins.fontconfig',
|
Extension('calibre.plugins.fontconfig',
|
||||||
@ -113,15 +124,6 @@ if __name__ == '__main__':
|
|||||||
['src/calibre/gui2/pictureflow/pictureflow.sip']
|
['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:
|
if isosx:
|
||||||
ext_modules.append(Extension('calibre.plugins.usbobserver',
|
ext_modules.append(Extension('calibre.plugins.usbobserver',
|
||||||
sources=['src/calibre/devices/usbobserver/usbobserver.c'],
|
sources=['src/calibre/devices/usbobserver/usbobserver.c'],
|
||||||
|
@ -308,7 +308,7 @@ get_all_removable_disks(struct tagDrives *g_drives)
|
|||||||
|
|
||||||
static DEVINST
|
static DEVINST
|
||||||
GetDrivesDevInstByDeviceNumber(long DeviceNumber,
|
GetDrivesDevInstByDeviceNumber(long DeviceNumber,
|
||||||
UINT DriveType, char* szDosDeviceName)
|
UINT DriveType, LPWSTR szDosDeviceName)
|
||||||
{
|
{
|
||||||
GUID *guid;
|
GUID *guid;
|
||||||
HDEVINFO hDevInfo;
|
HDEVINFO hDevInfo;
|
||||||
@ -319,8 +319,12 @@ GetDrivesDevInstByDeviceNumber(long DeviceNumber,
|
|||||||
long res;
|
long res;
|
||||||
HANDLE hDrive;
|
HANDLE hDrive;
|
||||||
STORAGE_DEVICE_NUMBER sdn;
|
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) {
|
switch (DriveType) {
|
||||||
case DRIVE_REMOVABLE:
|
case DRIVE_REMOVABLE:
|
||||||
@ -357,12 +361,7 @@ GetDrivesDevInstByDeviceNumber(long DeviceNumber,
|
|||||||
bRet = FALSE;
|
bRet = FALSE;
|
||||||
|
|
||||||
|
|
||||||
pspdidd =
|
pspdidd = (PSP_DEVICE_INTERFACE_DETAIL_DATA)Buf;
|
||||||
(PSP_DEVICE_INTERFACE_DETAIL_DATA)Buf;
|
|
||||||
SP_DEVICE_INTERFACE_DATA spdid;
|
|
||||||
SP_DEVINFO_DATA spdd;
|
|
||||||
DWORD dwSize;
|
|
||||||
|
|
||||||
spdid.cbSize = sizeof(spdid);
|
spdid.cbSize = sizeof(spdid);
|
||||||
|
|
||||||
while ( TRUE ) {
|
while ( TRUE ) {
|
||||||
@ -420,8 +419,11 @@ GetDrivesDevInstByDeviceNumber(long DeviceNumber,
|
|||||||
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
eject_drive_letter(char DriveLetter) {
|
eject_drive_letter(WCHAR DriveLetter) {
|
||||||
char szRootPath[4], szDevicePath[3], szVolumeAccessPath[7], szDosDeviceName[MAX_PATH];
|
LPWSTR szRootPath = L"X:\\",
|
||||||
|
szDevicePath = L"X:",
|
||||||
|
szVolumeAccessPath = L"\\\\.\\X:";
|
||||||
|
WCHAR szDosDeviceName[MAX_PATH];
|
||||||
long DeviceNumber, res, tries;
|
long DeviceNumber, res, tries;
|
||||||
HANDLE hVolume;
|
HANDLE hVolume;
|
||||||
STORAGE_DEVICE_NUMBER sdn;
|
STORAGE_DEVICE_NUMBER sdn;
|
||||||
@ -429,17 +431,15 @@ eject_drive_letter(char DriveLetter) {
|
|||||||
DEVINST DevInst;
|
DEVINST DevInst;
|
||||||
ULONG Status;
|
ULONG Status;
|
||||||
ULONG ProblemNumber;
|
ULONG ProblemNumber;
|
||||||
|
UINT DriveType;
|
||||||
PNP_VETO_TYPE VetoType;
|
PNP_VETO_TYPE VetoType;
|
||||||
WCHAR VetoNameW[MAX_PATH];
|
WCHAR VetoNameW[MAX_PATH];
|
||||||
BOOL bSuccess;
|
BOOL bSuccess;
|
||||||
DEVINST DevInstParent;
|
DEVINST DevInstParent;
|
||||||
|
|
||||||
szRootPath[0] = DriveLetter; szRootPath[1] = ':'; szRootPath[2] = '\\'; szRootPath[3] = (char)0;
|
szRootPath[0] = DriveLetter;
|
||||||
szDevicePath[0] = DriveLetter; szDevicePath[1] = ':'; szDevicePath[2] = (char)0;
|
szDevicePath[0] = DriveLetter;
|
||||||
szVolumeAccessPath[0] = '\\'; szVolumeAccessPath[1] = '\\'; szVolumeAccessPath[2] = '.';
|
szVolumeAccessPath[4] = DriveLetter;
|
||||||
szVolumeAccessPath[3] = '\\'; szVolumeAccessPath[4] = DriveLetter; szVolumeAccessPath[5] = ':';
|
|
||||||
szVolumeAccessPath[6] = (char)0;
|
|
||||||
|
|
||||||
|
|
||||||
DeviceNumber = -1;
|
DeviceNumber = -1;
|
||||||
|
|
||||||
@ -472,6 +472,8 @@ eject_drive_letter(char DriveLetter) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DriveType = GetDriveType(szRootPath);
|
||||||
|
|
||||||
DevInst = GetDrivesDevInstByDeviceNumber(DeviceNumber,
|
DevInst = GetDrivesDevInstByDeviceNumber(DeviceNumber,
|
||||||
DriveType, szDosDeviceName);
|
DriveType, szDosDeviceName);
|
||||||
if (DevInst == 0) return FALSE;
|
if (DevInst == 0) return FALSE;
|
||||||
@ -479,7 +481,6 @@ eject_drive_letter(char DriveLetter) {
|
|||||||
DevInstParent = 0;
|
DevInstParent = 0;
|
||||||
Status = 0;
|
Status = 0;
|
||||||
ProblemNumber = 0;
|
ProblemNumber = 0;
|
||||||
PNP_VETO_TYPE VetoType;
|
|
||||||
bSuccess = FALSE;
|
bSuccess = FALSE;
|
||||||
|
|
||||||
res = CM_Get_Parent(&DevInstParent, DevInst, 0);
|
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 (!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;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user