123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- /*
- * SetupAPI DiskSpace functions
- *
- * Copyright 2004 CodeWeavers (Aric Stewart)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- #include <stdarg.h>
- #include "windef.h"
- #include "winbase.h"
- #include "wingdi.h"
- #include "winuser.h"
- #include "winnls.h"
- #include "winreg.h"
- #include "setupapi.h"
- #include "wine/debug.h"
- WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
- typedef struct {
- WCHAR lpzName[20];
- LONGLONG dwFreeSpace;
- LONGLONG dwWantedSpace;
- } DRIVE_ENTRY, *LPDRIVE_ENTRY;
- typedef struct {
- DWORD dwDriveCount;
- DRIVE_ENTRY Drives[26];
- } DISKSPACELIST, *LPDISKSPACELIST;
- /***********************************************************************
- * SetupCreateDiskSpaceListW (SETUPAPI.@)
- */
- HDSKSPC WINAPI SetupCreateDiskSpaceListW(PVOID Reserved1, DWORD Reserved2, UINT Flags)
- {
- WCHAR drives[255];
- DWORD rc;
- WCHAR *ptr;
- LPDISKSPACELIST list=NULL;
- rc = GetLogicalDriveStringsW(255,drives);
- if (rc == 0)
- return NULL;
- list = (LPDISKSPACELIST)HeapAlloc(GetProcessHeap(),0,sizeof(DISKSPACELIST));
- list->dwDriveCount = 0;
-
- ptr = drives;
-
- while (*ptr)
- {
- DWORD type = GetDriveTypeW(ptr);
- DWORD len;
- if (type == DRIVE_FIXED)
- {
- DWORD clusters;
- DWORD sectors;
- DWORD bytes;
- DWORD total;
- lstrcpyW(list->Drives[list->dwDriveCount].lpzName,ptr);
- GetDiskFreeSpaceW(ptr,§ors,&bytes,&clusters,&total);
- list->Drives[list->dwDriveCount].dwFreeSpace = clusters * sectors *
- bytes;
- list->Drives[list->dwDriveCount].dwWantedSpace = 0;
- list->dwDriveCount++;
- }
- len = lstrlenW(ptr);
- len++;
- ptr+=sizeof(WCHAR)*len;
- }
- return (HANDLE)list;
- }
- /***********************************************************************
- * SetupCreateDiskSpaceListA (SETUPAPI.@)
- */
- HDSKSPC WINAPI SetupCreateDiskSpaceListA(PVOID Reserved1, DWORD Reserved2, UINT Flags)
- {
- return SetupCreateDiskSpaceListW( Reserved1, Reserved2, Flags );
- }
- /***********************************************************************
- * SetupAddInstallSectionToDiskSpaceListA (SETUPAPI.@)
- */
- BOOL WINAPI SetupAddInstallSectionToDiskSpaceListA(HDSKSPC DiskSpace,
- HINF InfHandle, HINF LayoutInfHandle,
- LPSTR SectionName, PVOID Reserved1, UINT Reserved2)
- {
- FIXME ("Stub\n");
- return TRUE;
- }
- /***********************************************************************
- * SetupQuerySpaceRequiredOnDriveA (SETUPAPI.@)
- */
- BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace,
- LPSTR DriveSpec, LONGLONG* SpaceRequired,
- PVOID Reserved1, UINT Reserved2)
- {
- WCHAR driveW[20];
- unsigned int i;
- LPDISKSPACELIST list = (LPDISKSPACELIST)DiskSpace;
- BOOL rc = FALSE;
- static const WCHAR bkslsh[]= {'\\',0};
- MultiByteToWideChar(CP_ACP,0,DriveSpec,-1,driveW,20);
- lstrcatW(driveW,bkslsh);
- TRACE("Looking for drive %s\n",debugstr_w(driveW));
-
- for (i = 0; i < list->dwDriveCount; i++)
- {
- TRACE("checking drive %s\n",debugstr_w(list->Drives[i].lpzName));
- if (lstrcmpW(driveW,list->Drives[i].lpzName)==0)
- {
- rc = TRUE;
- *SpaceRequired = list->Drives[i].dwWantedSpace;
- break;
- }
- }
- return rc;
- }
- /***********************************************************************
- * SetupDestroyDiskSpaceList (SETUPAPI.@)
- */
- BOOL WINAPI SetupDestroyDiskSpaceList(HDSKSPC DiskSpace)
- {
- LPDISKSPACELIST list = (LPDISKSPACELIST)DiskSpace;
- HeapFree(GetProcessHeap(),0,list);
- return TRUE;
- }
|