ReactOS 0.4.15-dev-7196-g0fe0b40
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/* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/
17
18/* A simplified version of SetupQueueCopyW that wraps Cabinet support around */
19BOOL
22 IN HSPFILEQ QueueHandle,
23 IN PCWSTR SourceRootPath,
24 IN PCWSTR SourcePath OPTIONAL,
25 IN PCWSTR SourceFileName,
26 IN PCWSTR SourceDescription OPTIONAL,
27 IN PCWSTR SourceCabinet OPTIONAL,
28 IN PCWSTR SourceTagFile OPTIONAL,
29 IN PCWSTR TargetDirectory,
30 IN PCWSTR TargetFileName OPTIONAL,
31 IN ULONG CopyStyle)
32{
33 WCHAR Win32SourceRootPath[MAX_PATH];
34 WCHAR Win32TargetDirectory[MAX_PATH];
35
36 /*
37 * SpFileQueueCopy is called within setuplib with NT paths, however
38 * the Win32 SetupQueueCopyW API only takes Win32 paths. We therefore
39 * map the NT path to Win32 path and then call the Win32 API.
40 */
42 Win32SourceRootPath,
43 _countof(Win32SourceRootPath),
44 SourceRootPath))
45 {
46 return FALSE;
47 }
48 /* SourcePath, SourceFileName and SourceCabinet are appended to SourceRootPath by the SetupApi function */
49
51 Win32TargetDirectory,
52 _countof(Win32TargetDirectory),
53 TargetDirectory))
54 {
55 return FALSE;
56 }
57 /* TargetFileName is appended to TargetDirectory by the SetupApi function */
58
59 /*
60 * Use the undocumented way of copying files from within a given cabinet file
61 * *ONLY IF* the files do not already exist in the same directory where
62 * the cabinet file resides!!
63 */
64 return SetupQueueCopyW(QueueHandle,
65 Win32SourceRootPath,
66 SourcePath,
67 SourceFileName,
68 // Undocumented on MSDN is the fact that this parameter is mandatory *IF* one wants to take the TagFile into account!
69 L"ReactOS",
70 // SourceTagFile -- Special behaviour: use cabinet file present in ArchiveDir path! The API does not check for a ".cab" extension.
71 SourceCabinet,
72 Win32TargetDirectory,
73 TargetFileName,
74 // We choose to decompress the archive, so do NOT specify SP_COPY_NODECOMP !
75 SP_COPY_NOOVERWRITE /* | SP_COPY_SOURCE_ABSOLUTE | SP_COPY_SOURCEPATH_ABSOLUTE */
76 );
77}
78
79BOOL
82 IN HSPFILEQ QueueHandle,
83 IN PCWSTR PathPart1,
84 IN PCWSTR PathPart2 OPTIONAL)
85{
86 WCHAR Win32PathPart1[MAX_PATH];
87
88 /*
89 * SpFileQueueDelete is called within setuplib with NT paths, however
90 * the Win32 SetupQueueDeleteW API only takes Win32 paths. We therefore
91 * map the NT path to Win32 path and then call the Win32 API.
92 */
94 Win32PathPart1,
95 _countof(Win32PathPart1),
96 PathPart1))
97 {
98 return FALSE;
99 }
100 /* PathPart2 is appended to PathPart1 by the SetupApi function */
101
102 return SetupQueueDeleteW(QueueHandle, Win32PathPart1, PathPart2);
103}
104
105BOOL
106WINAPI
108 IN HSPFILEQ QueueHandle,
109 IN PCWSTR SourcePath,
110 IN PCWSTR SourceFileName OPTIONAL,
111 IN PCWSTR TargetPath OPTIONAL,
112 IN PCWSTR TargetFileName)
113{
114 WCHAR Win32SourcePath[MAX_PATH];
115 WCHAR Win32TargetPath[MAX_PATH];
116
117 /*
118 * SpFileQueueRename is called within setuplib with NT paths, however
119 * the Win32 SetupQueueRenameW API only takes Win32 paths. We therefore
120 * map the NT path to Win32 path and then call the Win32 API.
121 */
123 Win32SourcePath,
124 _countof(Win32SourcePath),
125 SourcePath))
126 {
127 return FALSE;
128 }
129 /* SourceFileName is appended to SourcePath by the SetupApi function */
130
131 if (TargetPath)
132 {
134 Win32TargetPath,
135 _countof(Win32TargetPath),
136 TargetPath))
137 {
138 return FALSE;
139 }
140 }
141 /* TargetFileName is appended to TargetPath by the SetupApi function */
142
143 return SetupQueueRenameW(QueueHandle,
144 Win32SourcePath,
145 SourceFileName,
146 TargetPath ? Win32TargetPath : NULL,
147 TargetFileName);
148}
149
150
151/* GLOBALS *******************************************************************/
152
159
160/* EOF */
BOOL ConvertNtPathToWin32Path(IN OUT PNT_WIN32_PATH_MAPPING_LIST MappingList, OUT PWSTR pwszPath, IN DWORD cchPathMax, IN PCWSTR pwszNTPath)
Definition: reactos.c:1498
SETUPDATA SetupData
Definition: reactos.c:41
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
HSPFILEQ WINAPI SetupOpenFileQueue(void)
Definition: queue.c:445
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:156
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:154
pSpFileQueueCopy SpFileQueueCopy
Definition: fileqsup.c:155
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:153
pSpFileQueueCommit SpFileQueueCommit
Definition: fileqsup.c:158
pSpFileQueueRename SpFileQueueRename
Definition: fileqsup.c:157
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
BOOL WINAPI SpFileQueueDelete_NtToWin32(IN HSPFILEQ QueueHandle, IN PCWSTR PathPart1, IN PCWSTR PathPart2 OPTIONAL)
Definition: fileqsup.c:81
BOOL WINAPI SpFileQueueCopy_NtToWin32(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.c:21
BOOL WINAPI SpFileQueueRename_NtToWin32(IN HSPFILEQ QueueHandle, IN PCWSTR SourcePath, IN PCWSTR SourceFileName OPTIONAL, IN PCWSTR TargetPath OPTIONAL, IN PCWSTR TargetFileName)
Definition: fileqsup.c:107
#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
BOOL WINAPI SetupQueueRenameW(IN HSPFILEQ QueueHandle, IN PCWSTR SourcePath, IN PCWSTR SourceFileName OPTIONAL, IN PCWSTR TargetPath OPTIONAL, IN PCWSTR TargetFileName)
Definition: fileqsup.c:503
BOOL WINAPI SetupQueueDeleteW(IN HSPFILEQ QueueHandle, IN PCWSTR PathPart1, IN PCWSTR PathPart2 OPTIONAL)
Definition: fileqsup.c:433
BOOL WINAPI SetupCloseFileQueue(IN HSPFILEQ QueueHandle)
Definition: fileqsup.c:217
BOOL WINAPI SetupCommitFileQueueW(IN HWND Owner, IN HSPFILEQ QueueHandle, IN PSP_FILE_CALLBACK_W MsgHandler, IN PVOID Context OPTIONAL)
Definition: fileqsup.c:617
#define WINAPI
Definition: msvc.h:6
__wchar_t WCHAR
Definition: xmlstorage.h:180