ReactOS  0.4.14-dev-554-g2f8d847
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 */
19 BOOL
20 WINAPI
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 
79 BOOL
80 WINAPI
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 
105 BOOL
106 WINAPI
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 */
pSpFileQueueOpen SpFileQueueOpen
Definition: fileqsup.c:153
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
BOOL(WINAPI * pSpFileQueueRename)(IN HSPFILEQ QueueHandle, IN PCWSTR SourcePath, IN PCWSTR SourceFileName OPTIONAL, IN PCWSTR TargetPath OPTIONAL, IN PCWSTR TargetFileName)
Definition: fileqsup.h:117
pSpFileQueueCommit SpFileQueueCommit
Definition: fileqsup.c:158
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
#define _countof(array)
Definition: fontsub.cpp:30
BOOL WINAPI SetupQueueRenameW(IN HSPFILEQ QueueHandle, IN PCWSTR SourcePath, IN PCWSTR SourceFileName OPTIONAL, IN PCWSTR TargetPath OPTIONAL, IN PCWSTR TargetFileName)
Definition: fileqsup.c:503
HSPFILEQ WINAPI SetupOpenFileQueue(VOID)
Definition: fileqsup.c:161
BOOL(WINAPI * pSpFileQueueClose)(IN HSPFILEQ QueueHandle)
Definition: fileqsup.h:85
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:622
pSpFileQueueClose SpFileQueueClose
Definition: fileqsup.c:154
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI SpFileQueueDelete_NtToWin32(IN HSPFILEQ QueueHandle, IN PCWSTR PathPart1, IN PCWSTR PathPart2 OPTIONAL)
Definition: fileqsup.c:81
pSpFileQueueCopy SpFileQueueCopy
Definition: fileqsup.c:155
smooth NULL
Definition: ftsmooth.c:416
BOOL ConvertNtPathToWin32Path(IN OUT PNT_WIN32_PATH_MAPPING_LIST MappingList, OUT PWSTR pwszPath, IN DWORD cchPathMax, IN PCWSTR pwszNTPath)
Definition: reactos.c:1498
#define SP_COPY_NOOVERWRITE
Definition: setupapi.h:475
NT_WIN32_PATH_MAPPING_LIST MappingList
Definition: reactos.h:126
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
pSpFileQueueRename SpFileQueueRename
Definition: fileqsup.c:157
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
BOOL WINAPI SetupQueueDeleteW(IN HSPFILEQ QueueHandle, IN PCWSTR PathPart1, IN PCWSTR PathPart2 OPTIONAL)
Definition: fileqsup.c:433
HSPFILEQ(WINAPI * pSpFileQueueOpen)(VOID)
Definition: fileqsup.h:79
SETUPDATA SetupData
Definition: reactos.c:41
BOOL WINAPI SetupCommitFileQueueW(IN HWND Owner, IN HSPFILEQ QueueHandle, IN PSP_FILE_CALLBACK_W MsgHandler, IN PVOID Context OPTIONAL)
Definition: fileqsup.c:617
static const WCHAR L[]
Definition: oid.c:1250
BOOL(WINAPI * pSpFileQueueDelete)(IN HSPFILEQ QueueHandle, IN PCWSTR PathPart1, IN PCWSTR PathPart2 OPTIONAL)
Definition: fileqsup.h:108
BOOL(WINAPI * pSpFileQueueCommit)(IN HWND Owner, IN HSPFILEQ QueueHandle, IN PSP_FILE_CALLBACK_W MsgHandler, IN PVOID Context OPTIONAL)
Definition: fileqsup.h:128
unsigned int ULONG
Definition: retypes.h:1
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
pSpFileQueueDelete SpFileQueueDelete
Definition: fileqsup.c:156
BOOL WINAPI SetupCloseFileQueue(IN HSPFILEQ QueueHandle)
Definition: fileqsup.c:217
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68