ReactOS 0.4.15-dev-7958-gcd0bb1a
fileqsup.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS GUI first stage setup application
4 * FILE: base/setup/lib/fileqsup.c
5 * PURPOSE: Interfacing with Setup* API File Queue support functions
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9/* INCLUDES *****************************************************************/
10
11#include "reactos.h"
12
13#define NDEBUG
14#include <debug.h>
15
16#ifndef WINE_SETUPAPI_CAB_EXTRACTION_IS_NOT_SLOW_ANYMORE
17
18#define _USETUP_PCH_ // Disable USetup header inclusion
19
20#define NTOS_MODE_USER
21#include <ndk/mmfuncs.h>
22#include <ndk/obfuncs.h>
23
24#include <ntstrsafe.h>
25
26#include "../../usetup/spapisup/cabinet.h"
27#include "../../usetup/spapisup/cabinet.c"
28
29#define SetupOpenFileQueue _SetupOpenFileQueue
30#define SetupCloseFileQueue _SetupCloseFileQueue
31#define SetupQueueDeleteW _SetupQueueDeleteW
32#define SetupQueueRenameW _SetupQueueRenameW
33#define SetupCommitFileQueueW _SetupCommitFileQueueW
34
35#include "../../usetup/spapisup/fileqsup.c"
36
37#else
38
39/* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/
40
41/* A simplified version of SetupQueueCopyW that wraps Cabinet support around */
42BOOL
44SpFileQueueCopy_NtToWin32(
45 IN HSPFILEQ QueueHandle,
46 IN PCWSTR SourceRootPath,
47 IN PCWSTR SourcePath OPTIONAL,
48 IN PCWSTR SourceFileName,
49 IN PCWSTR SourceDescription OPTIONAL,
50 IN PCWSTR SourceCabinet OPTIONAL,
51 IN PCWSTR SourceTagFile OPTIONAL,
52 IN PCWSTR TargetDirectory,
53 IN PCWSTR TargetFileName OPTIONAL,
54 IN ULONG CopyStyle)
55{
56 WCHAR Win32SourceRootPath[MAX_PATH];
57 WCHAR Win32TargetDirectory[MAX_PATH];
58
59 /*
60 * SpFileQueueCopy is called within setuplib with NT paths, however
61 * the Win32 SetupQueueCopyW API only takes Win32 paths. We therefore
62 * map the NT path to Win32 path and then call the Win32 API.
63 */
65 Win32SourceRootPath,
66 _countof(Win32SourceRootPath),
67 SourceRootPath))
68 {
69 return FALSE;
70 }
71 /* SourcePath, SourceFileName and SourceCabinet are appended to SourceRootPath by the SetupApi function */
72
74 Win32TargetDirectory,
75 _countof(Win32TargetDirectory),
76 TargetDirectory))
77 {
78 return FALSE;
79 }
80 /* TargetFileName is appended to TargetDirectory by the SetupApi function */
81
82 /*
83 * Use the undocumented way of copying files from within a given cabinet file
84 * *ONLY IF* the files do not already exist in the same directory where
85 * the cabinet file resides!!
86 */
87 return SetupQueueCopyW(QueueHandle,
88 Win32SourceRootPath,
89 SourcePath,
90 SourceFileName,
91 // Undocumented on MSDN is the fact that this parameter is mandatory *IF* one wants to take the TagFile into account!
92 L"ReactOS",
93 // SourceTagFile -- Special behaviour: use cabinet file present in ArchiveDir path! The API does not check for a ".cab" extension.
94 SourceCabinet,
95 Win32TargetDirectory,
96 TargetFileName,
97 // We choose to decompress the archive, so do NOT specify SP_COPY_NODECOMP !
98 SP_COPY_NOOVERWRITE /* | SP_COPY_SOURCE_ABSOLUTE | SP_COPY_SOURCEPATH_ABSOLUTE */
99 );
100}
101
102BOOL
103WINAPI
104SpFileQueueDelete_NtToWin32(
105 IN HSPFILEQ QueueHandle,
106 IN PCWSTR PathPart1,
107 IN PCWSTR PathPart2 OPTIONAL)
108{
109 WCHAR Win32PathPart1[MAX_PATH];
110
111 /*
112 * SpFileQueueDelete is called within setuplib with NT paths, however
113 * the Win32 SetupQueueDeleteW API only takes Win32 paths. We therefore
114 * map the NT path to Win32 path and then call the Win32 API.
115 */
117 Win32PathPart1,
118 _countof(Win32PathPart1),
119 PathPart1))
120 {
121 return FALSE;
122 }
123 /* PathPart2 is appended to PathPart1 by the SetupApi function */
124
125 return SetupQueueDeleteW(QueueHandle, Win32PathPart1, PathPart2);
126}
127
128BOOL
129WINAPI
130SpFileQueueRename_NtToWin32(
131 IN HSPFILEQ QueueHandle,
132 IN PCWSTR SourcePath,
133 IN PCWSTR SourceFileName OPTIONAL,
134 IN PCWSTR TargetPath OPTIONAL,
135 IN PCWSTR TargetFileName)
136{
137 WCHAR Win32SourcePath[MAX_PATH];
138 WCHAR Win32TargetPath[MAX_PATH];
139
140 /*
141 * SpFileQueueRename is called within setuplib with NT paths, however
142 * the Win32 SetupQueueRenameW API only takes Win32 paths. We therefore
143 * map the NT path to Win32 path and then call the Win32 API.
144 */
146 Win32SourcePath,
147 _countof(Win32SourcePath),
148 SourcePath))
149 {
150 return FALSE;
151 }
152 /* SourceFileName is appended to SourcePath by the SetupApi function */
153
154 if (TargetPath)
155 {
157 Win32TargetPath,
158 _countof(Win32TargetPath),
159 TargetPath))
160 {
161 return FALSE;
162 }
163 }
164 /* TargetFileName is appended to TargetPath by the SetupApi function */
165
166 return SetupQueueRenameW(QueueHandle,
167 Win32SourcePath,
168 SourceFileName,
169 TargetPath ? Win32TargetPath : NULL,
170 TargetFileName);
171}
172
173
174/* GLOBALS *******************************************************************/
175
178pSpFileQueueCopy SpFileQueueCopy = SpFileQueueCopy_NtToWin32;
179pSpFileQueueDelete SpFileQueueDelete = SpFileQueueDelete_NtToWin32;
180pSpFileQueueRename SpFileQueueRename = SpFileQueueRename_NtToWin32;
182
183#endif
184
185/* EOF */
BOOL ConvertNtPathToWin32Path(IN OUT PNT_WIN32_PATH_MAPPING_LIST MappingList, OUT PWSTR pwszPath, IN DWORD cchPathMax, IN PCWSTR pwszNTPath)
Definition: reactos.c:1523
SETUPDATA SetupData
Definition: reactos.c:42
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI SetupQueueCopyW(HSPFILEQ queue, PCWSTR src_root, PCWSTR src_path, PCWSTR src_file, PCWSTR src_descr, PCWSTR src_tag, PCWSTR dst_dir, PCWSTR dst_file, DWORD style)
Definition: queue.c:574
BOOL(WINAPI * pSpFileQueueCommit)(IN HWND Owner, IN HSPFILEQ QueueHandle, IN PSP_FILE_CALLBACK_W MsgHandler, IN PVOID Context OPTIONAL)
Definition: fileqsup.h:128
pSpFileQueueDelete SpFileQueueDelete
Definition: fileqsup.c:1003
BOOL(WINAPI * pSpFileQueueClose)(IN HSPFILEQ QueueHandle)
Definition: fileqsup.h:85
BOOL(WINAPI * pSpFileQueueDelete)(IN HSPFILEQ QueueHandle, IN PCWSTR PathPart1, IN PCWSTR PathPart2 OPTIONAL)
Definition: fileqsup.h:108
pSpFileQueueClose SpFileQueueClose
Definition: fileqsup.c:1001
pSpFileQueueCopy SpFileQueueCopy
Definition: fileqsup.c:1002
BOOL(WINAPI * pSpFileQueueCopy)(IN HSPFILEQ QueueHandle, IN PCWSTR SourceRootPath, IN PCWSTR SourcePath OPTIONAL, IN PCWSTR SourceFileName, IN PCWSTR SourceDescription OPTIONAL, IN PCWSTR SourceCabinet OPTIONAL, IN PCWSTR SourceTagFile OPTIONAL, IN PCWSTR TargetDirectory, IN PCWSTR TargetFileName OPTIONAL, IN ULONG CopyStyle)
Definition: fileqsup.h:92
HSPFILEQ(WINAPI * pSpFileQueueOpen)(VOID)
Definition: fileqsup.h:79
pSpFileQueueOpen SpFileQueueOpen
Definition: fileqsup.c:1000
pSpFileQueueCommit SpFileQueueCommit
Definition: fileqsup.c:1005
pSpFileQueueRename SpFileQueueRename
Definition: fileqsup.c:1004
BOOL(WINAPI * pSpFileQueueRename)(IN HSPFILEQ QueueHandle, IN PCWSTR SourcePath, IN PCWSTR SourceFileName OPTIONAL, IN PCWSTR TargetPath OPTIONAL, IN PCWSTR TargetFileName)
Definition: fileqsup.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define L(x)
Definition: ntvdm.h:50
#define SetupQueueDeleteW
Definition: fileqsup.c:31
#define SetupOpenFileQueue
Definition: fileqsup.c:29
#define SetupQueueRenameW
Definition: fileqsup.c:32
#define SetupCommitFileQueueW
Definition: fileqsup.c:33
#define SetupCloseFileQueue
Definition: fileqsup.c:30
#define SP_COPY_NOOVERWRITE
Definition: setupapi.h:480
#define _countof(array)
Definition: sndvol32.h:68
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
NT_WIN32_PATH_MAPPING_LIST MappingList
Definition: reactos.h:126
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
__wchar_t WCHAR
Definition: xmlstorage.h:180