summaryrefslogtreecommitdiff
path: root/src/inc/longfilepathwrappers.h
blob: a8479889354c69395fbc27a493bea00c5c54f2e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
// Licensed to the .NET Foundation under one or more agreements. 
// The .NET Foundation licenses this file to you under the MIT license. 
// See the LICENSE file in the project root for more information. 

#ifndef _WIN_PATH_APIS_WRAPPER_
#define _WIN_PATH_APIS_WRAPPER_
class SString;

HMODULE
LoadLibraryExWrapper(
    _In_ LPCWSTR lpLibFileName,
    _Reserved_ HANDLE hFile = NULL,
    _In_ DWORD dwFlags = 0
    );

HANDLE
CreateFileWrapper(
    _In_ LPCWSTR lpFileName,
    _In_ DWORD dwDesiredAccess,
    _In_ DWORD dwShareMode,
    _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
    _In_ DWORD dwCreationDisposition,
    _In_ DWORD dwFlagsAndAttributes,
    _In_opt_ HANDLE hTemplateFile
    );

BOOL
SetFileAttributesWrapper(
    _In_ LPCWSTR lpFileName,
    _In_ DWORD dwFileAttributes
    );

DWORD
GetFileAttributesWrapper(
    _In_ LPCWSTR lpFileName
    );

BOOL
GetFileAttributesExWrapper(
    _In_ LPCWSTR lpFileName,
    _In_ GET_FILEEX_INFO_LEVELS fInfoLevelId,
    _Out_writes_bytes_(sizeof(WIN32_FILE_ATTRIBUTE_DATA)) LPVOID lpFileInformation
    );
BOOL
DeleteFileWrapper(
    _In_ LPCWSTR lpFileName
    );

HANDLE
FindFirstFileExWrapper(
    _In_ LPCWSTR lpFileName,
    _In_ FINDEX_INFO_LEVELS fInfoLevelId,
    _Out_writes_bytes_(sizeof(WIN32_FIND_DATAW)) LPVOID lpFindFileData,
    _In_ FINDEX_SEARCH_OPS fSearchOp,
    _Reserved_ LPVOID lpSearchFilter,
    _In_ DWORD dwAdditionalFlags
    );

BOOL
CopyFileWrapper(
    _In_ LPCWSTR lpExistingFileName,
    _In_ LPCWSTR lpNewFileName,
    _In_ BOOL bFailIfExists
    );

#ifndef FEATURE_PAL
BOOL
CopyFileExWrapper(
    _In_        LPCWSTR lpExistingFileName,
    _In_        LPCWSTR lpNewFileName,
    _In_opt_    LPPROGRESS_ROUTINE lpProgressRoutine,
    _In_opt_    LPVOID lpData,
    _When_(pbCancel != NULL, _Pre_satisfies_(*pbCancel == FALSE))
    _Inout_opt_ LPBOOL pbCancel,
    _In_        DWORD dwCopyFlags
    );
#endif //FEATURE_PAL

BOOL
MoveFileExWrapper(
    _In_     LPCWSTR lpExistingFileName,
    _In_opt_ LPCWSTR lpNewFileName,
    _In_     DWORD    dwFlags
    );

BOOL
CreateDirectoryWrapper(
    _In_ LPCWSTR lpPathName,
    _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes
    );

BOOL
RemoveDirectoryWrapper(
    _In_ LPCWSTR lpPathName
    );

BOOL
CreateHardLinkWrapper(
    _In_       LPCWSTR lpFileName,
    _In_       LPCWSTR lpExistingFileName,
    _Reserved_ LPSECURITY_ATTRIBUTES lpSecurityAttributes
    );

DWORD
SearchPathWrapper(
    _In_opt_ LPCWSTR lpPath,
    _In_ LPCWSTR lpFileName,
    _In_opt_ LPCWSTR lpExtension,
    _In_ BOOL getPath,
    SString& lpBuffer,
    _Out_opt_ LPWSTR * lpFilePart
    );


DWORD
GetShortPathNameWrapper(
    _In_ LPCWSTR lpszLongPath,
    SString& lpszShortPath
    );

DWORD
GetLongPathNameWrapper(
    _In_ LPCWSTR lpszShortPath,
    SString& lpszLongPath
    );

UINT GetTempFileNameWrapper(
    _In_  LPCTSTR lpPathName,
    _In_  LPCTSTR lpPrefixString,
    _In_  UINT    uUnique,
    SString&  lpTempFileName
    );

DWORD GetTempPathWrapper(
    SString& lpBuffer
    );

DWORD GetCurrentDirectoryWrapper(
    SString&  lpBuffer
    );

DWORD
GetModuleFileNameWrapper(
    _In_opt_ HMODULE hModule,
    SString& buffer
    );

DWORD GetEnvironmentVariableWrapper(
    _In_opt_  LPCTSTR lpName,
    _Out_opt_ SString&  lpBuffer
    );

BOOL PAL_GetPALDirectoryWrapper(SString& pbuffer);

#ifndef FEATURE_CORECLR
//Temporarily providing direct OS Calls Till All of the Desktop CLR start using the above format
inline DWORD
SearchPathWrapper(
    _In_opt_ LPCWSTR lpPath,
    _In_ LPCWSTR lpFileName,
    _In_opt_ LPCWSTR lpExtension,
    _In_ BOOL getPath,
    _Out_     LPWSTR  lpBuffer,
    _Out_opt_ LPWSTR * lpFilePart
    )
{
    return SearchPathW(
        lpPath,
        lpFileName,
        lpExtension,
        getPath,
        lpBuffer,
        lpFilePart
        );
}


inline DWORD
GetShortPathNameWrapper(
    _In_ LPCWSTR lpszLongPath,
    _Out_ LPWSTR  lpszShortPath,
    _In_  DWORD   cchBuffer
    )
{
    return GetShortPathNameW(
        lpszLongPath,
        lpszShortPath,
        cchBuffer
        );
}

inline DWORD
GetLongPathNameWrapper(
    _In_ LPCWSTR lpszShortPath,
    _Out_ LPWSTR  lpszLongPath,
    _In_  DWORD   cchBuffer
    )
{
    return GetLongPathNameW(
        lpszShortPath,
        lpszLongPath,
        cchBuffer
        );
}

inline UINT GetTempFileNameWrapper(
    _In_  LPCWSTR lpPathName,
    _In_  LPCWSTR lpPrefixString,
    _In_  UINT    uUnique,
    _Out_ LPWSTR  lpTempFileName
    )
{
    return GetTempFileNameW(
        lpPathName,
        lpPrefixString,
        uUnique,
        lpTempFileName
        );
}

inline DWORD GetTempPathWrapper(
    _In_  DWORD  nBufferLength,
    _Out_ LPWSTR lpBuffer
    )
{
    return GetTempPathW(
        nBufferLength,
        lpBuffer
        );
}

inline DWORD GetCurrentDirectoryWrapper(
    _In_  DWORD  nBufferLength,
    _Out_ LPWSTR lpBuffer
    )
{
    return GetCurrentDirectoryW(
        nBufferLength,
        lpBuffer
        );
}

inline DWORD
GetModuleFileNameWrapper(
    _In_opt_ HMODULE hModule,
    _Out_    LPWSTR  lpFilename,
    _In_     DWORD   nSize
    )
{
    return GetModuleFileNameW(
        hModule,
        lpFilename,
        nSize
        );
}

inline DWORD GetEnvironmentVariableWrapper(
    _In_opt_  LPCWSTR lpName,
    _Out_opt_ LPWSTR  lpBuffer,
    _In_      DWORD   nSize
    )
{
    return GetEnvironmentVariableW(
       lpName,
       lpBuffer,
       nSize
        );
}
#endif //FEATURE_CORECLR
#endif //_WIN_PATH_APIS_WRAPPER_