2004-03-17 02:46:00 +01:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2005-03-24 22:01:35 +01:00
|
|
|
list = HeapAlloc(GetProcessHeap(),0,sizeof(DISKSPACELIST));
|
2004-03-17 02:46:00 +01:00
|
|
|
|
|
|
|
list->dwDriveCount = 0;
|
|
|
|
|
|
|
|
ptr = drives;
|
|
|
|
|
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
DWORD type = GetDriveTypeW(ptr);
|
|
|
|
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++;
|
|
|
|
}
|
2005-07-10 19:39:26 +02:00
|
|
|
ptr += lstrlenW(ptr) + 1;
|
2004-03-17 02:46:00 +01:00
|
|
|
}
|
|
|
|
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,
|
2005-09-14 12:06:17 +02:00
|
|
|
LPCSTR SectionName, PVOID Reserved1, UINT Reserved2)
|
2004-03-17 02:46:00 +01:00
|
|
|
{
|
|
|
|
FIXME ("Stub\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupQuerySpaceRequiredOnDriveA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace,
|
2005-09-14 12:06:17 +02:00
|
|
|
LPCSTR DriveSpec, LONGLONG* SpaceRequired,
|
2004-03-17 02:46:00 +01:00
|
|
|
PVOID Reserved1, UINT Reserved2)
|
|
|
|
{
|
|
|
|
WCHAR driveW[20];
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2004-03-17 02:46:00 +01:00
|
|
|
LPDISKSPACELIST list = (LPDISKSPACELIST)DiskSpace;
|
|
|
|
BOOL rc = FALSE;
|
2004-04-20 03:12:17 +02:00
|
|
|
static const WCHAR bkslsh[]= {'\\',0};
|
2004-03-17 02:46:00 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|