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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-03-17 02:46:00 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2010-09-07 12:00:29 +02:00
|
|
|
TRACE("(%p, %u, 0x%08x)\n", Reserved1, Reserved2, Flags);
|
|
|
|
|
|
|
|
if (Reserved1 || Reserved2 || Flags & ~SPDSL_IGNORE_DISK)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-17 02:46:00 +01:00
|
|
|
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
|
|
|
}
|
2008-12-08 04:06:20 +01:00
|
|
|
return list;
|
2004-03-17 02:46:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupCreateDiskSpaceListA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HDSKSPC WINAPI SetupCreateDiskSpaceListA(PVOID Reserved1, DWORD Reserved2, UINT Flags)
|
|
|
|
{
|
|
|
|
return SetupCreateDiskSpaceListW( Reserved1, Reserved2, Flags );
|
|
|
|
}
|
|
|
|
|
2010-09-07 12:01:11 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDuplicateDiskSpaceListW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HDSKSPC WINAPI SetupDuplicateDiskSpaceListW(HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags)
|
|
|
|
{
|
|
|
|
DISKSPACELIST *list_copy, *list_original = DiskSpace;
|
|
|
|
|
|
|
|
if (Reserved1 || Reserved2 || Flags)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!DiskSpace)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
list_copy = HeapAlloc(GetProcessHeap(), 0, sizeof(DISKSPACELIST));
|
|
|
|
if (!list_copy)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*list_copy = *list_original;
|
|
|
|
|
|
|
|
return list_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDuplicateDiskSpaceListA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HDSKSPC WINAPI SetupDuplicateDiskSpaceListA(HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags)
|
|
|
|
{
|
|
|
|
return SetupDuplicateDiskSpaceListW(DiskSpace, Reserved1, Reserved2, Flags);
|
|
|
|
}
|
2004-03-17 02:46:00 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2010-09-07 12:00:39 +02:00
|
|
|
* SetupQuerySpaceRequiredOnDriveW (SETUPAPI.@)
|
2004-03-17 02:46:00 +01:00
|
|
|
*/
|
2010-09-07 12:00:39 +02:00
|
|
|
BOOL WINAPI SetupQuerySpaceRequiredOnDriveW(HDSKSPC DiskSpace,
|
|
|
|
LPCWSTR DriveSpec, LONGLONG *SpaceRequired,
|
2004-03-17 02:46:00 +01:00
|
|
|
PVOID Reserved1, UINT Reserved2)
|
|
|
|
{
|
2010-09-07 12:00:39 +02:00
|
|
|
WCHAR *driveW;
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2009-01-28 10:24:55 +01:00
|
|
|
LPDISKSPACELIST list = DiskSpace;
|
2004-03-17 02:46:00 +01:00
|
|
|
BOOL rc = FALSE;
|
2004-04-20 03:12:17 +02:00
|
|
|
static const WCHAR bkslsh[]= {'\\',0};
|
2004-03-17 02:46:00 +01:00
|
|
|
|
2010-09-07 12:00:56 +02:00
|
|
|
if (!DiskSpace)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!DriveSpec)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-01-15 09:28:30 +01:00
|
|
|
driveW = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(DriveSpec) + 2) * sizeof(WCHAR));
|
2010-09-07 12:00:39 +02:00
|
|
|
if (!driveW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-03-17 02:46:00 +01:00
|
|
|
|
2010-09-07 12:00:39 +02:00
|
|
|
lstrcpyW(driveW,DriveSpec);
|
2004-03-17 02:46:00 +01:00
|
|
|
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));
|
2019-07-04 15:41:03 +02:00
|
|
|
if (wcscmp(driveW,list->Drives[i].lpzName)==0)
|
2004-03-17 02:46:00 +01:00
|
|
|
{
|
|
|
|
rc = TRUE;
|
|
|
|
*SpaceRequired = list->Drives[i].dwWantedSpace;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-07 12:00:39 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, driveW);
|
|
|
|
|
2010-09-07 12:00:56 +02:00
|
|
|
if (!rc) SetLastError(ERROR_INVALID_DRIVE);
|
2004-03-17 02:46:00 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-09-07 12:00:39 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupQuerySpaceRequiredOnDriveA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace,
|
|
|
|
LPCSTR DriveSpec, LONGLONG *SpaceRequired,
|
|
|
|
PVOID Reserved1, UINT Reserved2)
|
|
|
|
{
|
2010-09-07 12:00:56 +02:00
|
|
|
DWORD len;
|
|
|
|
LPWSTR DriveSpecW;
|
2010-09-07 12:00:39 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2010-09-07 12:00:56 +02:00
|
|
|
/* The parameter validation checks are in a different order from the
|
|
|
|
* Unicode variant of SetupQuerySpaceRequiredOnDrive. */
|
|
|
|
if (!DriveSpec)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!DiskSpace)
|
2010-09-07 12:00:39 +02:00
|
|
|
{
|
2010-09-07 12:00:56 +02:00
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-09-07 12:00:39 +02:00
|
|
|
|
2010-09-07 12:00:56 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, NULL, 0);
|
2010-09-07 12:00:39 +02:00
|
|
|
|
2010-09-07 12:00:56 +02:00
|
|
|
DriveSpecW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!DriveSpecW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
2010-09-07 12:00:39 +02:00
|
|
|
}
|
|
|
|
|
2010-09-07 12:00:56 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, DriveSpecW, len);
|
|
|
|
|
2010-09-07 12:00:39 +02:00
|
|
|
ret = SetupQuerySpaceRequiredOnDriveW(DiskSpace, DriveSpecW, SpaceRequired,
|
|
|
|
Reserved1, Reserved2);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, DriveSpecW);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-03-17 02:46:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDestroyDiskSpaceList (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDestroyDiskSpaceList(HDSKSPC DiskSpace)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
LPDISKSPACELIST list = DiskSpace;
|
2004-03-17 02:46:00 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,list);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2012-01-25 23:35:42 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupAddToDiskSpaceListA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupAddToDiskSpaceListA(HDSKSPC diskspace, PCSTR targetfile,
|
|
|
|
LONGLONG filesize, UINT operation,
|
|
|
|
PVOID reserved1, UINT reserved2)
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupAddToDiskSpaceListW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupAddToDiskSpaceListW(HDSKSPC diskspace, PCWSTR targetfile,
|
|
|
|
LONGLONG filesize, UINT operation,
|
|
|
|
PVOID reserved1, UINT reserved2)
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|