2 * SetupAPI DiskSpace functions
4 * Copyright 2004 CodeWeavers (Aric Stewart)
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.
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.
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
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(setupapi
);
37 LONGLONG dwWantedSpace
;
38 } DRIVE_ENTRY
, *LPDRIVE_ENTRY
;
42 DRIVE_ENTRY Drives
[26];
43 } DISKSPACELIST
, *LPDISKSPACELIST
;
46 /***********************************************************************
47 * SetupCreateDiskSpaceListW (SETUPAPI.@)
49 HDSKSPC WINAPI
SetupCreateDiskSpaceListW(PVOID Reserved1
, DWORD Reserved2
, UINT Flags
)
54 LPDISKSPACELIST list
=NULL
;
56 rc
= GetLogicalDriveStringsW(255,drives
);
61 list
= HeapAlloc(GetProcessHeap(),0,sizeof(DISKSPACELIST
));
63 list
->dwDriveCount
= 0;
69 DWORD type
= GetDriveTypeW(ptr
);
70 if (type
== DRIVE_FIXED
)
76 lstrcpyW(list
->Drives
[list
->dwDriveCount
].lpzName
,ptr
);
77 GetDiskFreeSpaceW(ptr
,§ors
,&bytes
,&clusters
,&total
);
78 list
->Drives
[list
->dwDriveCount
].dwFreeSpace
= clusters
* sectors
*
80 list
->Drives
[list
->dwDriveCount
].dwWantedSpace
= 0;
83 ptr
+= lstrlenW(ptr
) + 1;
89 /***********************************************************************
90 * SetupCreateDiskSpaceListA (SETUPAPI.@)
92 HDSKSPC WINAPI
SetupCreateDiskSpaceListA(PVOID Reserved1
, DWORD Reserved2
, UINT Flags
)
94 return SetupCreateDiskSpaceListW( Reserved1
, Reserved2
, Flags
);
98 /***********************************************************************
99 * SetupAddInstallSectionToDiskSpaceListA (SETUPAPI.@)
101 BOOL WINAPI
SetupAddInstallSectionToDiskSpaceListA(HDSKSPC DiskSpace
,
102 HINF InfHandle
, HINF LayoutInfHandle
,
103 LPCSTR SectionName
, PVOID Reserved1
, UINT Reserved2
)
109 /***********************************************************************
110 * SetupQuerySpaceRequiredOnDriveA (SETUPAPI.@)
112 BOOL WINAPI
SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace
,
113 LPCSTR DriveSpec
, LONGLONG
* SpaceRequired
,
114 PVOID Reserved1
, UINT Reserved2
)
118 LPDISKSPACELIST list
= (LPDISKSPACELIST
)DiskSpace
;
120 static const WCHAR bkslsh
[]= {'\\',0};
122 MultiByteToWideChar(CP_ACP
,0,DriveSpec
,-1,driveW
,20);
124 lstrcatW(driveW
,bkslsh
);
126 TRACE("Looking for drive %s\n",debugstr_w(driveW
));
128 for (i
= 0; i
< list
->dwDriveCount
; i
++)
130 TRACE("checking drive %s\n",debugstr_w(list
->Drives
[i
].lpzName
));
131 if (lstrcmpW(driveW
,list
->Drives
[i
].lpzName
)==0)
134 *SpaceRequired
= list
->Drives
[i
].dwWantedSpace
;
142 /***********************************************************************
143 * SetupDestroyDiskSpaceList (SETUPAPI.@)
145 BOOL WINAPI
SetupDestroyDiskSpaceList(HDSKSPC DiskSpace
)
147 LPDISKSPACELIST list
= (LPDISKSPACELIST
)DiskSpace
;
148 HeapFree(GetProcessHeap(),0,list
);