[pywin32-checkins] pywin32/win32/src win32file.i,1.49,1.50
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2005-11-13 08:40:59
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27316/win32/src Modified Files: win32file.i Log Message: Add QueryDosDevice Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** win32file.i 1 Nov 2005 21:24:09 -0000 1.49 --- win32file.i 13 Nov 2005 08:40:50 -0000 1.50 *************** *** 1513,1518 **** #endif // MS_WINCE ! // QueryDosDevice ! %{ --- 1513,1557 ---- #endif // MS_WINCE ! // @pyswig string|QueryDosDevice|Returns the mapping for a device name, or all device names ! %native (QueryDosDevice) MyQueryDosDevice; ! %{ ! static PyObject *MyQueryDosDevice(PyObject *self, PyObject *args) ! { ! PyObject *ret=NULL; ! char *devicename, *targetpath=NULL; ! DWORD retlen, buflen, err; ! // @pyparm string|DeviceName||Name of device to query, or None to return all defined devices ! // @rdesc Returns a string containing substrings separated by NULLs with 2 terminating NULLs ! if (!PyArg_ParseTuple(args, "z:QueryDosDevice", &devicename)) ! return NULL; ! if (devicename==NULL) // this returns a huge string ! buflen=8192; ! else ! buflen=256; ! // function returns ERROR_INSUFFICIENT_BUFFER with no indication of how much memory is actually needed ! while (true){ ! if (targetpath){ ! free(targetpath); ! buflen*=2; ! } ! targetpath=(char *)malloc(buflen); ! if (targetpath==NULL) ! return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", buflen); ! retlen=QueryDosDevice(devicename, targetpath, buflen); ! if (retlen!=0){ ! ret=PyString_FromStringAndSize(targetpath, retlen); ! break; ! } ! err=GetLastError(); ! if (err!=ERROR_INSUFFICIENT_BUFFER){ ! PyWin_SetAPIError("QueryDosDevice",err); ! break; ! } ! } ! if (targetpath) ! free(targetpath); ! return ret; ! } ! %} %{ *************** *** 2688,2691 **** --- 2727,2731 ---- + // @pyswig <o PyUnicode>|SetVolumeMountPoint|Mounts the specified volume at the specified volume mount point. static PyObject* *************** *** 3522,3526 **** return Py_BuildValue("ll", bytes_written, ctxt); } - %} --- 3562,3565 ---- *************** *** 3607,3611 **** fp = GetProcAddress(hmodule, "BackupWrite"); if (fp) pfnBackupWrite = (BOOL (WINAPI *)(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*))(fp); - } %} --- 3646,3649 ---- |