ReactOS 0.4.15-dev-7958-gcd0bb1a
diskspace.c
Go to the documentation of this file.
1/*
2 * SetupAPI DiskSpace functions
3 *
4 * Copyright 2004 CodeWeavers (Aric Stewart)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "setupapi_private.h"
22
23typedef struct {
24 WCHAR lpzName[20];
28
29typedef struct {
31 DRIVE_ENTRY Drives[26];
33
34
35/***********************************************************************
36 * SetupCreateDiskSpaceListW (SETUPAPI.@)
37 */
39{
40 WCHAR drives[255];
41 DWORD rc;
42 WCHAR *ptr;
44
45 TRACE("(%p, %u, 0x%08x)\n", Reserved1, Reserved2, Flags);
46
48 {
50 return NULL;
51 }
52
53 rc = GetLogicalDriveStringsW(255,drives);
54
55 if (rc == 0)
56 return NULL;
57
59
60 list->dwDriveCount = 0;
61
62 ptr = drives;
63
64 while (*ptr)
65 {
67 if (type == DRIVE_FIXED)
68 {
69 DWORD clusters;
73 lstrcpyW(list->Drives[list->dwDriveCount].lpzName,ptr);
75 list->Drives[list->dwDriveCount].dwFreeSpace = clusters * sectors *
76 bytes;
77 list->Drives[list->dwDriveCount].dwWantedSpace = 0;
78 list->dwDriveCount++;
79 }
80 ptr += lstrlenW(ptr) + 1;
81 }
82 return list;
83}
84
85
86/***********************************************************************
87 * SetupCreateDiskSpaceListA (SETUPAPI.@)
88 */
90{
92}
93
94/***********************************************************************
95 * SetupDuplicateDiskSpaceListW (SETUPAPI.@)
96 */
98{
99 DISKSPACELIST *list_copy, *list_original = DiskSpace;
100
101 if (Reserved1 || Reserved2 || Flags)
102 {
104 return NULL;
105 }
106
107 if (!DiskSpace)
108 {
110 return NULL;
111 }
112
113 list_copy = HeapAlloc(GetProcessHeap(), 0, sizeof(DISKSPACELIST));
114 if (!list_copy)
115 {
117 return NULL;
118 }
119
120 *list_copy = *list_original;
121
122 return list_copy;
123}
124
125/***********************************************************************
126 * SetupDuplicateDiskSpaceListA (SETUPAPI.@)
127 */
129{
131}
132
133/***********************************************************************
134 * SetupAddInstallSectionToDiskSpaceListA (SETUPAPI.@)
135 */
137 HINF InfHandle, HINF LayoutInfHandle,
138 LPCSTR SectionName, PVOID Reserved1, UINT Reserved2)
139{
140 FIXME ("Stub\n");
141 return TRUE;
142}
143
144/***********************************************************************
145* SetupQuerySpaceRequiredOnDriveW (SETUPAPI.@)
146*/
148 LPCWSTR DriveSpec, LONGLONG *SpaceRequired,
150{
151 WCHAR *driveW;
152 unsigned int i;
153 LPDISKSPACELIST list = DiskSpace;
154 BOOL rc = FALSE;
155 static const WCHAR bkslsh[]= {'\\',0};
156
157 if (!DiskSpace)
158 {
160 return FALSE;
161 }
162
163 if (!DriveSpec)
164 {
166 return FALSE;
167 }
168
169 driveW = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(DriveSpec) + 2) * sizeof(WCHAR));
170 if (!driveW)
171 {
173 return FALSE;
174 }
175
176 lstrcpyW(driveW,DriveSpec);
177 lstrcatW(driveW,bkslsh);
178
179 TRACE("Looking for drive %s\n",debugstr_w(driveW));
180
181 for (i = 0; i < list->dwDriveCount; i++)
182 {
183 TRACE("checking drive %s\n",debugstr_w(list->Drives[i].lpzName));
184 if (lstrcmpW(driveW,list->Drives[i].lpzName)==0)
185 {
186 rc = TRUE;
187 *SpaceRequired = list->Drives[i].dwWantedSpace;
188 break;
189 }
190 }
191
192 HeapFree(GetProcessHeap(), 0, driveW);
193
195 return rc;
196}
197
198/***********************************************************************
199* SetupQuerySpaceRequiredOnDriveA (SETUPAPI.@)
200*/
202 LPCSTR DriveSpec, LONGLONG *SpaceRequired,
204{
205 DWORD len;
206 LPWSTR DriveSpecW;
207 BOOL ret;
208
209 /* The parameter validation checks are in a different order from the
210 * Unicode variant of SetupQuerySpaceRequiredOnDrive. */
211 if (!DriveSpec)
212 {
214 return FALSE;
215 }
216
217 if (!DiskSpace)
218 {
220 return FALSE;
221 }
222
223 len = MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, NULL, 0);
224
225 DriveSpecW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
226 if (!DriveSpecW)
227 {
229 return FALSE;
230 }
231
232 MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, DriveSpecW, len);
233
234 ret = SetupQuerySpaceRequiredOnDriveW(DiskSpace, DriveSpecW, SpaceRequired,
236
237 HeapFree(GetProcessHeap(), 0, DriveSpecW);
238
239 return ret;
240}
241
242/***********************************************************************
243* SetupDestroyDiskSpaceList (SETUPAPI.@)
244*/
246{
249 return TRUE;
250}
251
252/***********************************************************************
253* SetupAddToDiskSpaceListA (SETUPAPI.@)
254*/
256 LONGLONG filesize, UINT operation,
257 PVOID reserved1, UINT reserved2)
258{
259 FIXME(": stub\n");
261 return FALSE;
262}
263
264/***********************************************************************
265* SetupAddToDiskSpaceListW (SETUPAPI.@)
266*/
268 LONGLONG filesize, UINT operation,
269 PVOID reserved1, UINT reserved2)
270{
271 FIXME(": stub\n");
273 return FALSE;
274}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
operation
Definition: copy.c:29
@ Reserved2
Definition: bcd.h:202
@ Reserved1
Definition: bcd.h:201
#define FIXME(fmt,...)
Definition: debug.h:111
Definition: list.h:37
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define lstrcpyW
Definition: compat.h:749
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrlenW
Definition: compat.h:750
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
DWORD WINAPI GetLogicalDriveStringsW(IN DWORD nBufferLength, IN LPWSTR lpBuffer)
Definition: disk.c:73
BOOL WINAPI GetDiskFreeSpaceW(IN LPCWSTR lpRootPathName, OUT LPDWORD lpSectorsPerCluster, OUT LPDWORD lpBytesPerSector, OUT LPDWORD lpNumberOfFreeClusters, OUT LPDWORD lpTotalNumberOfClusters)
Definition: disk.c:173
struct DRIVE_ENTRY * LPDRIVE_ENTRY
BOOL WINAPI SetupAddToDiskSpaceListW(HDSKSPC diskspace, PCWSTR targetfile, LONGLONG filesize, UINT operation, PVOID reserved1, UINT reserved2)
Definition: diskspace.c:267
HDSKSPC WINAPI SetupDuplicateDiskSpaceListW(HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags)
Definition: diskspace.c:97
HDSKSPC WINAPI SetupDuplicateDiskSpaceListA(HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags)
Definition: diskspace.c:128
BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace, LPCSTR DriveSpec, LONGLONG *SpaceRequired, PVOID Reserved1, UINT Reserved2)
Definition: diskspace.c:201
struct DISKSPACELIST * LPDISKSPACELIST
BOOL WINAPI SetupQuerySpaceRequiredOnDriveW(HDSKSPC DiskSpace, LPCWSTR DriveSpec, LONGLONG *SpaceRequired, PVOID Reserved1, UINT Reserved2)
Definition: diskspace.c:147
HDSKSPC WINAPI SetupCreateDiskSpaceListW(PVOID Reserved1, DWORD Reserved2, UINT Flags)
Definition: diskspace.c:38
BOOL WINAPI SetupAddToDiskSpaceListA(HDSKSPC diskspace, PCSTR targetfile, LONGLONG filesize, UINT operation, PVOID reserved1, UINT reserved2)
Definition: diskspace.c:255
BOOL WINAPI SetupDestroyDiskSpaceList(HDSKSPC DiskSpace)
Definition: diskspace.c:245
HDSKSPC WINAPI SetupCreateDiskSpaceListA(PVOID Reserved1, DWORD Reserved2, UINT Flags)
Definition: diskspace.c:89
BOOL WINAPI SetupAddInstallSectionToDiskSpaceListA(HDSKSPC DiskSpace, HINF InfHandle, HINF LayoutInfHandle, LPCSTR SectionName, PVOID Reserved1, UINT Reserved2)
Definition: diskspace.c:136
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
uint8_t reserved2[12]
Definition: fsck.fat.h:23
size_t total
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
__u8 sectors[2]
Definition: mkdosfs.c:8
static PVOID ptr
Definition: dispmode.c:27
unsigned int UINT
Definition: ndis.h:50
#define list
Definition: rosglue.h:35
#define SPDSL_IGNORE_DISK
Definition: setupapi.h:543
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwDriveCount
Definition: diskspace.c:30
Definition: diskspace.c:23
LONGLONG dwFreeSpace
Definition: diskspace.c:25
LONGLONG dwWantedSpace
Definition: diskspace.c:26
const uint16_t * PCWSTR
Definition: typedefs.h:57
int64_t LONGLONG
Definition: typedefs.h:68
const char * PCSTR
Definition: typedefs.h:52
int ret
#define DRIVE_FIXED
Definition: winbase.h:252
#define WINAPI
Definition: msvc.h:6
#define ERROR_INVALID_DRIVE
Definition: winerror.h:118
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185