~ubuntu-branches/ubuntu/vivid/freerdp/vivid

« back to all changes in this revision

Viewing changes to winpr/include/winpr/path.h

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-11-11 12:20:50 UTC
  • mfrom: (1.2.5)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20141111122050-7z628f4ab38qxad5
Tags: upstream-1.1.0~git20140921.1.440916e+dfsg1
ImportĀ upstreamĀ versionĀ 1.1.0~git20140921.1.440916e+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * WinPR: Windows Portable Runtime
 
3
 * Path Functions
 
4
 *
 
5
 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * Unless required by applicable law or agreed to in writing, software
 
14
 * distributed under the License is distributed on an "AS IS" BASIS,
 
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
 * See the License for the specific language governing permissions and
 
17
 * limitations under the License.
 
18
 */
 
19
 
 
20
#ifndef WINPR_PATH_H
 
21
#define WINPR_PATH_H
 
22
 
 
23
#include <winpr/winpr.h>
 
24
#include <winpr/tchar.h>
 
25
#include <winpr/error.h>
 
26
#include <winpr/wtypes.h>
 
27
 
 
28
//#define HAVE_PATHCCH_H        1
 
29
 
 
30
#ifdef HAVE_PATHCCH_H
 
31
 
 
32
#include <Pathcch.h>
 
33
 
 
34
#else
 
35
 
 
36
#ifdef __cplusplus
 
37
extern "C" {
 
38
#endif
 
39
 
 
40
#define PATHCCH_ALLOW_LONG_PATHS        0x00000001 /* Allow building of \\?\ paths if longer than MAX_PATH */
 
41
 
 
42
#define VOLUME_PREFIX                   _T("\\\\?\\Volume")
 
43
#define VOLUME_PREFIX_LEN               ((sizeof(VOLUME_PREFIX) / sizeof(TCHAR)) - 1)
 
44
 
 
45
/*
 
46
 * Maximum number of characters we support using the "\\?\" syntax
 
47
 * (0x7FFF + 1 for NULL terminator)
 
48
 */
 
49
 
 
50
#define PATHCCH_MAX_CCH                 0x8000
 
51
 
 
52
WINPR_API HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath);
 
53
WINPR_API HRESULT PathCchAddBackslashW(PWSTR pszPath, size_t cchPath);
 
54
 
 
55
WINPR_API HRESULT PathCchRemoveBackslashA(PSTR pszPath, size_t cchPath);
 
56
WINPR_API HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath);
 
57
 
 
58
WINPR_API HRESULT PathCchAddBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining);
 
59
WINPR_API HRESULT PathCchAddBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining);
 
60
 
 
61
WINPR_API HRESULT PathCchRemoveBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining);
 
62
WINPR_API HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining);
 
63
 
 
64
WINPR_API HRESULT PathCchAddExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt);
 
65
WINPR_API HRESULT PathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt);
 
66
 
 
67
WINPR_API HRESULT PathCchAppendA(PSTR pszPath, size_t cchPath, PCSTR pszMore);
 
68
WINPR_API HRESULT PathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore);
 
69
 
 
70
WINPR_API HRESULT PathCchAppendExA(PSTR pszPath, size_t cchPath, PCSTR pszMore, unsigned long dwFlags);
 
71
WINPR_API HRESULT PathCchAppendExW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore, unsigned long dwFlags);
 
72
 
 
73
WINPR_API HRESULT PathCchCanonicalizeA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn);
 
74
WINPR_API HRESULT PathCchCanonicalizeW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn);
 
75
 
 
76
WINPR_API HRESULT PathCchCanonicalizeExA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, unsigned long dwFlags);
 
77
WINPR_API HRESULT PathCchCanonicalizeExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, unsigned long dwFlags);
 
78
 
 
79
WINPR_API HRESULT PathAllocCanonicalizeA(PCSTR pszPathIn, unsigned long dwFlags, PSTR* ppszPathOut);
 
80
WINPR_API HRESULT PathAllocCanonicalizeW(PCWSTR pszPathIn, unsigned long dwFlags, PWSTR* ppszPathOut);
 
81
 
 
82
WINPR_API HRESULT PathCchCombineA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, PCSTR pszMore);
 
83
WINPR_API HRESULT PathCchCombineW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, PCWSTR pszMore);
 
84
 
 
85
WINPR_API HRESULT PathCchCombineExA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags);
 
86
WINPR_API HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags);
 
87
 
 
88
WINPR_API HRESULT PathAllocCombineA(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags, PSTR* ppszPathOut);
 
89
WINPR_API HRESULT PathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags, PWSTR* ppszPathOut);
 
90
 
 
91
WINPR_API HRESULT PathCchFindExtensionA(PCSTR pszPath, size_t cchPath, PCSTR* ppszExt);
 
92
WINPR_API HRESULT PathCchFindExtensionW(PCWSTR pszPath, size_t cchPath, PCWSTR* ppszExt);
 
93
 
 
94
WINPR_API HRESULT PathCchRenameExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt);
 
95
WINPR_API HRESULT PathCchRenameExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt);
 
96
 
 
97
WINPR_API HRESULT PathCchRemoveExtensionA(PSTR pszPath, size_t cchPath);
 
98
WINPR_API HRESULT PathCchRemoveExtensionW(PWSTR pszPath, size_t cchPath);
 
99
 
 
100
WINPR_API BOOL PathCchIsRootA(PCSTR pszPath);
 
101
WINPR_API BOOL PathCchIsRootW(PCWSTR pszPath);
 
102
 
 
103
WINPR_API BOOL PathIsUNCExA(PCSTR pszPath, PCSTR* ppszServer);
 
104
WINPR_API BOOL PathIsUNCExW(PCWSTR pszPath, PCWSTR* ppszServer);
 
105
 
 
106
WINPR_API HRESULT PathCchSkipRootA(PCSTR pszPath, PCSTR* ppszRootEnd);
 
107
WINPR_API HRESULT PathCchSkipRootW(PCWSTR pszPath, PCWSTR* ppszRootEnd);
 
108
 
 
109
WINPR_API HRESULT PathCchStripToRootA(PSTR pszPath, size_t cchPath);
 
110
WINPR_API HRESULT PathCchStripToRootW(PWSTR pszPath, size_t cchPath);
 
111
 
 
112
WINPR_API HRESULT PathCchStripPrefixA(PSTR pszPath, size_t cchPath);
 
113
WINPR_API HRESULT PathCchStripPrefixW(PWSTR pszPath, size_t cchPath);
 
114
 
 
115
WINPR_API HRESULT PathCchRemoveFileSpecA(PSTR pszPath, size_t cchPath);
 
116
WINPR_API HRESULT PathCchRemoveFileSpecW(PWSTR pszPath, size_t cchPath);
 
117
 
 
118
 
 
119
#ifdef UNICODE
 
120
#define PathCchAddBackslash             PathCchAddBackslashW
 
121
#define PathCchRemoveBackslash          PathCchRemoveBackslashW
 
122
#define PathCchAddBackslashEx           PathCchAddBackslashExW
 
123
#define PathCchRemoveBackslashEx        PathCchRemoveBackslashExW
 
124
#define PathCchAddExtension             PathCchAddExtensionW
 
125
#define PathCchAppend                   PathCchAppendW
 
126
#define PathCchAppendEx                 PathCchAppendExW
 
127
#define PathCchCanonicalize             PathCchCanonicalizeW
 
128
#define PathCchCanonicalizeEx           PathCchCanonicalizeExW
 
129
#define PathAllocCanonicalize           PathAllocCanonicalizeW
 
130
#define PathCchCombine                  PathCchCombineW
 
131
#define PathCchCombineEx                PathCchCombineExW
 
132
#define PathAllocCombine                PathAllocCombineW
 
133
#define PathCchFindExtension            PathCchFindExtensionW
 
134
#define PathCchRenameExtension          PathCchRenameExtensionW
 
135
#define PathCchRemoveExtension          PathCchRemoveExtensionW
 
136
#define PathCchIsRoot                   PathCchIsRootW
 
137
#define PathIsUNCEx                     PathIsUNCExW
 
138
#define PathCchSkipRoot                 PathCchSkipRootW
 
139
#define PathCchStripToRoot              PathCchStripToRootW
 
140
#define PathCchStripPrefix              PathCchStripPrefixW
 
141
#define PathCchRemoveFileSpec           PathCchRemoveFileSpecW
 
142
#else
 
143
#define PathCchAddBackslash             PathCchAddBackslashA
 
144
#define PathCchRemoveBackslash          PathCchRemoveBackslashA
 
145
#define PathCchAddBackslashEx           PathCchAddBackslashExA
 
146
#define PathCchRemoveBackslashEx        PathCchRemoveBackslashExA
 
147
#define PathCchAddExtension             PathCchAddExtensionA
 
148
#define PathCchAppend                   PathCchAppendA
 
149
#define PathCchAppendEx                 PathCchAppendExA
 
150
#define PathCchCanonicalize             PathCchCanonicalizeA
 
151
#define PathCchCanonicalizeEx           PathCchCanonicalizeExA
 
152
#define PathAllocCanonicalize           PathAllocCanonicalizeA
 
153
#define PathCchCombine                  PathCchCombineA
 
154
#define PathCchCombineEx                PathCchCombineExA
 
155
#define PathAllocCombine                PathAllocCombineA
 
156
#define PathCchFindExtension            PathCchFindExtensionA
 
157
#define PathCchRenameExtension          PathCchRenameExtensionA
 
158
#define PathCchRemoveExtension          PathCchRemoveExtensionA
 
159
#define PathCchIsRoot                   PathCchIsRootA
 
160
#define PathIsUNCEx                     PathIsUNCExA
 
161
#define PathCchSkipRoot                 PathCchSkipRootA
 
162
#define PathCchStripToRoot              PathCchStripToRootA
 
163
#define PathCchStripPrefix              PathCchStripPrefixA
 
164
#define PathCchRemoveFileSpec           PathCchRemoveFileSpecA
 
165
#endif
 
166
 
 
167
/* Unix-style Paths */
 
168
 
 
169
WINPR_API HRESULT PathCchAddSlashA(PSTR pszPath, size_t cchPath);
 
170
WINPR_API HRESULT PathCchAddSlashW(PWSTR pszPath, size_t cchPath);
 
171
 
 
172
WINPR_API HRESULT PathCchAddSlashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining);
 
173
WINPR_API HRESULT PathCchAddSlashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining);
 
174
 
 
175
WINPR_API HRESULT UnixPathCchAddExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt);
 
176
WINPR_API HRESULT UnixPathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt);
 
177
 
 
178
WINPR_API HRESULT UnixPathCchAppendA(PSTR pszPath, size_t cchPath, PCSTR pszMore);
 
179
WINPR_API HRESULT UnixPathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore);
 
180
 
 
181
WINPR_API HRESULT UnixPathAllocCombineA(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags, PSTR* ppszPathOut);
 
182
WINPR_API HRESULT UnixPathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags, PWSTR* ppszPathOut);
 
183
 
 
184
#ifdef UNICODE
 
185
#define PathCchAddSlash                 PathCchAddSlashW
 
186
#define PathCchAddSlashEx               PathCchAddSlashExW
 
187
#define UnixPathCchAddExtension         UnixPathCchAddExtensionW
 
188
#define UnixPathCchAppend               UnixPathCchAppendW
 
189
#define UnixPathAllocCombine            UnixPathAllocCombineW
 
190
#else
 
191
#define PathCchAddSlash                 PathCchAddSlashA
 
192
#define PathCchAddSlashEx               PathCchAddSlashExA
 
193
#define UnixPathCchAddExtension         UnixPathCchAddExtensionA
 
194
#define UnixPathCchAppend               UnixPathCchAppendA
 
195
#define UnixPathAllocCombine            UnixPathAllocCombineA
 
196
#endif
 
197
 
 
198
/* Native-style Paths */
 
199
 
 
200
WINPR_API HRESULT PathCchAddSeparatorA(PSTR pszPath, size_t cchPath);
 
201
WINPR_API HRESULT PathCchAddSeparatorW(PWSTR pszPath, size_t cchPath);
 
202
 
 
203
WINPR_API HRESULT PathCchAddSeparatorExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining);
 
204
WINPR_API HRESULT PathCchAddSeparatorExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining);
 
205
 
 
206
WINPR_API HRESULT NativePathCchAddExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt);
 
207
WINPR_API HRESULT NativePathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt);
 
208
 
 
209
WINPR_API HRESULT NativePathCchAppendA(PSTR pszPath, size_t cchPath, PCSTR pszMore);
 
210
WINPR_API HRESULT NativePathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore);
 
211
 
 
212
WINPR_API HRESULT NativePathAllocCombineA(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags, PSTR* ppszPathOut);
 
213
WINPR_API HRESULT NativePathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags, PWSTR* ppszPathOut);
 
214
 
 
215
#ifdef UNICODE
 
216
#define PathCchAddSeparator             PathCchAddSeparatorW
 
217
#define PathCchAddSeparatorEx           PathCchAddSeparatorExW
 
218
#define NativePathCchAddExtension       NativePathCchAddExtensionW
 
219
#define NativePathCchAppend             NativePathCchAppendW
 
220
#define NativePathAllocCombine          NativePathAllocCombineW
 
221
#else
 
222
#define PathCchAddSeparator             PathCchAddSeparatorA
 
223
#define PathCchAddSeparatorEx           PathCchAddSeparatorExA
 
224
#define NativePathCchAddExtension       NativePathCchAddExtensionA
 
225
#define NativePathCchAppend             NativePathCchAppendA
 
226
#define NativePathAllocCombine          NativePathAllocCombineA
 
227
#endif
 
228
 
 
229
/* Path Portability Functions */
 
230
 
 
231
#define PATH_STYLE_WINDOWS                      0x00000001
 
232
#define PATH_STYLE_UNIX                         0x00000002
 
233
#define PATH_STYLE_NATIVE                       0x00000003
 
234
 
 
235
#define PATH_SHARED_LIB_EXT_WITH_DOT            0x00000001
 
236
#define PATH_SHARED_LIB_EXT_APPLE_SO            0x00000002
 
237
#define PATH_SHARED_LIB_EXT_EXPLICIT            0x80000000
 
238
#define PATH_SHARED_LIB_EXT_EXPLICIT_DLL        0x80000001
 
239
#define PATH_SHARED_LIB_EXT_EXPLICIT_SO         0x80000002
 
240
#define PATH_SHARED_LIB_EXT_EXPLICIT_DYLIB      0x80000003
 
241
 
 
242
WINPR_API HRESULT PathCchConvertStyleA(PSTR pszPath, size_t cchPath, unsigned long dwFlags);
 
243
WINPR_API HRESULT PathCchConvertStyleW(PWSTR pszPath, size_t cchPath, unsigned long dwFlags);
 
244
 
 
245
WINPR_API PCSTR PathGetSharedLibraryExtensionA(unsigned long dwFlags);
 
246
WINPR_API PCWSTR PathGetSharedLibraryExtensionW(unsigned long dwFlags);
 
247
 
 
248
#ifdef UNICODE
 
249
#define PathCchConvertStyle             PathCchConvertStyleW
 
250
#define PathGetSharedLibraryExtension   PathGetSharedLibraryExtensionW
 
251
#else
 
252
#define PathCchConvertStyle             PathCchConvertStyleA
 
253
#define PathGetSharedLibraryExtension   PathGetSharedLibraryExtensionA
 
254
#endif
 
255
 
 
256
#ifdef __cplusplus
 
257
}
 
258
#endif
 
259
 
 
260
#endif
 
261
 
 
262
/**
 
263
 * Shell Path Functions
 
264
 */
 
265
 
 
266
#define KNOWN_PATH_HOME                 1
 
267
#define KNOWN_PATH_TEMP                 2
 
268
#define KNOWN_PATH_XDG_DATA_HOME        3
 
269
#define KNOWN_PATH_XDG_CONFIG_HOME      4
 
270
#define KNOWN_PATH_XDG_CACHE_HOME       5
 
271
#define KNOWN_PATH_XDG_RUNTIME_DIR      6
 
272
 
 
273
#ifdef __cplusplus
 
274
extern "C" {
 
275
#endif
 
276
 
 
277
WINPR_API char* GetKnownPath(int id);
 
278
WINPR_API char* GetKnownSubPath(int id, char* path);
 
279
WINPR_API char* GetCombinedPath(char* basePath, char* subPath);
 
280
 
 
281
//#ifndef _WIN32
 
282
 
 
283
WINPR_API BOOL PathFileExistsA(LPCSTR pszPath);
 
284
WINPR_API BOOL PathFileExistsW(LPCWSTR pszPath);
 
285
 
 
286
#ifdef __cplusplus
 
287
}
 
288
#endif
 
289
 
 
290
#ifdef UNICODE
 
291
#define PathFileExists  PathFileExistsW
 
292
#else
 
293
#define PathFileExists  PathFileExistsA
 
294
#endif
 
295
 
 
296
//#endif
 
297
 
 
298
#endif /* WINPR_PATH_H */