1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
/*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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;
TRACE("(%p, %u, 0x%08x)\n", Reserved1, Reserved2, Flags);
if (Reserved1 || Reserved2 || Flags & ~SPDSL_IGNORE_DISK)
{
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
rc = GetLogicalDriveStringsW(255,drives);
if (rc == 0)
return NULL;
list = HeapAlloc(GetProcessHeap(),0,sizeof(DISKSPACELIST));
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++;
}
ptr += lstrlenW(ptr) + 1;
}
return list;
}
/***********************************************************************
* SetupCreateDiskSpaceListA (SETUPAPI.@)
*/
HDSKSPC WINAPI SetupCreateDiskSpaceListA(PVOID Reserved1, DWORD Reserved2, UINT Flags)
{
return SetupCreateDiskSpaceListW( Reserved1, Reserved2, Flags );
}
/***********************************************************************
* 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);
}
/***********************************************************************
* SetupAddInstallSectionToDiskSpaceListA (SETUPAPI.@)
*/
BOOL WINAPI SetupAddInstallSectionToDiskSpaceListA(HDSKSPC DiskSpace,
HINF InfHandle, HINF LayoutInfHandle,
LPCSTR SectionName, PVOID Reserved1, UINT Reserved2)
{
FIXME ("Stub\n");
return TRUE;
}
/***********************************************************************
* SetupQuerySpaceRequiredOnDriveW (SETUPAPI.@)
*/
BOOL WINAPI SetupQuerySpaceRequiredOnDriveW(HDSKSPC DiskSpace,
LPCWSTR DriveSpec, LONGLONG *SpaceRequired,
PVOID Reserved1, UINT Reserved2)
{
WCHAR *driveW;
unsigned int i;
LPDISKSPACELIST list = DiskSpace;
BOOL rc = FALSE;
static const WCHAR bkslsh[]= {'\\',0};
if (!DiskSpace)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (!DriveSpec)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
driveW = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(DriveSpec) + 2) * sizeof(WCHAR));
if (!driveW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
lstrcpyW(driveW,DriveSpec);
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;
}
}
HeapFree(GetProcessHeap(), 0, driveW);
if (!rc) SetLastError(ERROR_INVALID_DRIVE);
return rc;
}
/***********************************************************************
* SetupQuerySpaceRequiredOnDriveA (SETUPAPI.@)
*/
BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace,
LPCSTR DriveSpec, LONGLONG *SpaceRequired,
PVOID Reserved1, UINT Reserved2)
{
DWORD len;
LPWSTR DriveSpecW;
BOOL ret;
/* 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)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
len = MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, NULL, 0);
DriveSpecW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!DriveSpecW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, DriveSpecW, len);
ret = SetupQuerySpaceRequiredOnDriveW(DiskSpace, DriveSpecW, SpaceRequired,
Reserved1, Reserved2);
HeapFree(GetProcessHeap(), 0, DriveSpecW);
return ret;
}
/***********************************************************************
* SetupDestroyDiskSpaceList (SETUPAPI.@)
*/
BOOL WINAPI SetupDestroyDiskSpaceList(HDSKSPC DiskSpace)
{
LPDISKSPACELIST list = DiskSpace;
HeapFree(GetProcessHeap(),0,list);
return TRUE;
}
/***********************************************************************
* 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;
}
|