1 | /* $Id: shellpath.c,v 1.4 2001-04-03 18:42:42 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Path Functions
|
---|
4 | *
|
---|
5 | * Many of this functions are in SHLWAPI.DLL also
|
---|
6 | *
|
---|
7 | */
|
---|
8 | #ifdef __WIN32OS2__
|
---|
9 | #define ICOM_CINTERFACE 1
|
---|
10 | #include <odin.h>
|
---|
11 | #endif
|
---|
12 |
|
---|
13 | #include <string.h>
|
---|
14 | #include <ctype.h>
|
---|
15 | #include "debugtools.h"
|
---|
16 | #include "winnls.h"
|
---|
17 | #include "winreg.h"
|
---|
18 |
|
---|
19 | #include "shlobj.h"
|
---|
20 | #include "shell32_main.h"
|
---|
21 | #include "windef.h"
|
---|
22 | #include "options.h"
|
---|
23 | #include "wine/winestring.h"
|
---|
24 | #include "wine/undocshell.h"
|
---|
25 | #include "wine/unicode.h"
|
---|
26 | #include "shlwapi.h"
|
---|
27 |
|
---|
28 | DEFAULT_DEBUG_CHANNEL(shell);
|
---|
29 |
|
---|
30 | #define isSlash(x) ((x)=='\\' || (x)=='/')
|
---|
31 | /*
|
---|
32 | ########## Combining and Constructing paths ##########
|
---|
33 | */
|
---|
34 |
|
---|
35 | /*************************************************************************
|
---|
36 | * PathAppendAW [SHELL32.36]
|
---|
37 | */
|
---|
38 | BOOL WINAPI PathAppendAW(
|
---|
39 | LPVOID lpszPath1,
|
---|
40 | LPCVOID lpszPath2)
|
---|
41 | {
|
---|
42 | if (SHELL_OsIsUnicode())
|
---|
43 | return PathAppendW(lpszPath1, lpszPath2);
|
---|
44 | return PathAppendA(lpszPath1, lpszPath2);
|
---|
45 | }
|
---|
46 |
|
---|
47 | /*************************************************************************
|
---|
48 | * PathCombineAW [SHELL32.37]
|
---|
49 | */
|
---|
50 | LPVOID WINAPI PathCombineAW(
|
---|
51 | LPVOID szDest,
|
---|
52 | LPCVOID lpszDir,
|
---|
53 | LPCVOID lpszFile)
|
---|
54 | {
|
---|
55 | if (SHELL_OsIsUnicode())
|
---|
56 | return PathCombineW( szDest, lpszDir, lpszFile );
|
---|
57 | return PathCombineA( szDest, lpszDir, lpszFile );
|
---|
58 | }
|
---|
59 |
|
---|
60 | /*************************************************************************
|
---|
61 | * PathAddBackslashAW [SHELL32.32]
|
---|
62 | */
|
---|
63 | LPVOID WINAPI PathAddBackslashAW(LPVOID lpszPath)
|
---|
64 | {
|
---|
65 | if(SHELL_OsIsUnicode())
|
---|
66 | return PathAddBackslashW(lpszPath);
|
---|
67 | return PathAddBackslashA(lpszPath);
|
---|
68 | }
|
---|
69 |
|
---|
70 | /*************************************************************************
|
---|
71 | * PathBuildRootAW [SHELL32.30]
|
---|
72 | */
|
---|
73 | LPVOID WINAPI PathBuildRootAW(LPVOID lpszPath, int drive)
|
---|
74 | {
|
---|
75 | if(SHELL_OsIsUnicode())
|
---|
76 | return PathBuildRootW(lpszPath, drive);
|
---|
77 | return PathBuildRootA(lpszPath, drive);
|
---|
78 | }
|
---|
79 |
|
---|
80 | /*
|
---|
81 | Extracting Component Parts
|
---|
82 | */
|
---|
83 |
|
---|
84 | /*************************************************************************
|
---|
85 | * PathFindFileNameAW [SHELL32.34]
|
---|
86 | */
|
---|
87 | LPVOID WINAPI PathFindFileNameAW(LPCVOID lpszPath)
|
---|
88 | {
|
---|
89 | if(SHELL_OsIsUnicode())
|
---|
90 | return PathFindFileNameW(lpszPath);
|
---|
91 | return PathFindFileNameA(lpszPath);
|
---|
92 | }
|
---|
93 |
|
---|
94 | /*************************************************************************
|
---|
95 | * PathFindExtensionAW [SHELL32.31]
|
---|
96 | */
|
---|
97 | LPVOID WINAPI PathFindExtensionAW(LPCVOID lpszPath)
|
---|
98 | {
|
---|
99 | if (SHELL_OsIsUnicode())
|
---|
100 | return PathFindExtensionW(lpszPath);
|
---|
101 | return PathFindExtensionA(lpszPath);
|
---|
102 |
|
---|
103 | }
|
---|
104 |
|
---|
105 | /*************************************************************************
|
---|
106 | * PathGetExtensionA [internal]
|
---|
107 | *
|
---|
108 | * NOTES
|
---|
109 | * exported by ordinal
|
---|
110 | * return value points to the first char after the dot
|
---|
111 | */
|
---|
112 | static LPSTR PathGetExtensionA(LPCSTR lpszPath)
|
---|
113 | {
|
---|
114 | TRACE("(%s)\n",lpszPath);
|
---|
115 |
|
---|
116 | lpszPath = PathFindExtensionA(lpszPath);
|
---|
117 | return (LPSTR)(*lpszPath?(lpszPath+1):lpszPath);
|
---|
118 | }
|
---|
119 |
|
---|
120 | /*************************************************************************
|
---|
121 | * PathGetExtensionW [internal]
|
---|
122 | */
|
---|
123 | static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
|
---|
124 | {
|
---|
125 | TRACE("(%s)\n",debugstr_w(lpszPath));
|
---|
126 |
|
---|
127 | lpszPath = PathFindExtensionW(lpszPath);
|
---|
128 | return (LPWSTR)(*lpszPath?(lpszPath+1):lpszPath);
|
---|
129 | }
|
---|
130 |
|
---|
131 | /*************************************************************************
|
---|
132 | * PathGetExtensionAW [SHELL32.158]
|
---|
133 | */
|
---|
134 | LPVOID WINAPI PathGetExtensionAW(LPCVOID lpszPath)
|
---|
135 | {
|
---|
136 | if (SHELL_OsIsUnicode())
|
---|
137 | return PathGetExtensionW(lpszPath);
|
---|
138 | return PathGetExtensionA(lpszPath);
|
---|
139 | }
|
---|
140 |
|
---|
141 | /*************************************************************************
|
---|
142 | * PathGetArgsAW [SHELL32.52]
|
---|
143 | */
|
---|
144 | LPVOID WINAPI PathGetArgsAW(LPVOID lpszPath)
|
---|
145 | {
|
---|
146 | if (SHELL_OsIsUnicode())
|
---|
147 | return PathGetArgsW(lpszPath);
|
---|
148 | return PathGetArgsA(lpszPath);
|
---|
149 | }
|
---|
150 |
|
---|
151 | /*************************************************************************
|
---|
152 | * PathGetDriveNumber [SHELL32.57]
|
---|
153 | */
|
---|
154 | int WINAPI PathGetDriveNumberAW(LPVOID lpszPath)
|
---|
155 | {
|
---|
156 | if (SHELL_OsIsUnicode())
|
---|
157 | return PathGetDriveNumberW(lpszPath);
|
---|
158 | return PathGetDriveNumberA(lpszPath);
|
---|
159 | }
|
---|
160 |
|
---|
161 | /*************************************************************************
|
---|
162 | * PathRemoveFileSpec [SHELL32.35]
|
---|
163 | */
|
---|
164 | BOOL WINAPI PathRemoveFileSpecAW(LPVOID lpszPath)
|
---|
165 | {
|
---|
166 | if (SHELL_OsIsUnicode())
|
---|
167 | return PathRemoveFileSpecW(lpszPath);
|
---|
168 | return PathRemoveFileSpecA(lpszPath);
|
---|
169 | }
|
---|
170 |
|
---|
171 | /*************************************************************************
|
---|
172 | * PathStripPathAW [SHELL32.38]
|
---|
173 | */
|
---|
174 | void WINAPI PathStripPathAW(LPVOID lpszPath)
|
---|
175 | {
|
---|
176 | if (SHELL_OsIsUnicode())
|
---|
177 | return PathStripPathW(lpszPath);
|
---|
178 | return PathStripPathA(lpszPath);
|
---|
179 | }
|
---|
180 |
|
---|
181 | /*************************************************************************
|
---|
182 | * PathStripToRootAW [SHELL32.50]
|
---|
183 | */
|
---|
184 | BOOL WINAPI PathStripToRootAW(LPVOID lpszPath)
|
---|
185 | {
|
---|
186 | if (SHELL_OsIsUnicode())
|
---|
187 | return PathStripToRootW(lpszPath);
|
---|
188 | return PathStripToRootA(lpszPath);
|
---|
189 | }
|
---|
190 |
|
---|
191 | /*************************************************************************
|
---|
192 | * PathRemoveArgsAW [SHELL32.251]
|
---|
193 | */
|
---|
194 | void WINAPI PathRemoveArgsAW(LPVOID lpszPath)
|
---|
195 | {
|
---|
196 | if (SHELL_OsIsUnicode())
|
---|
197 | PathRemoveArgsW(lpszPath);
|
---|
198 | PathRemoveArgsA(lpszPath);
|
---|
199 | }
|
---|
200 |
|
---|
201 | /*************************************************************************
|
---|
202 | * PathRemoveExtensionAW [SHELL32.250]
|
---|
203 | */
|
---|
204 | void WINAPI PathRemoveExtensionAW(LPVOID lpszPath)
|
---|
205 | {
|
---|
206 | if (SHELL_OsIsUnicode())
|
---|
207 | return PathRemoveExtensionW(lpszPath);
|
---|
208 | return PathRemoveExtensionA(lpszPath);
|
---|
209 | }
|
---|
210 |
|
---|
211 |
|
---|
212 | /*
|
---|
213 | Path Manipulations
|
---|
214 | */
|
---|
215 |
|
---|
216 | /*************************************************************************
|
---|
217 | * PathGetShortPathA [internal]
|
---|
218 | */
|
---|
219 | LPSTR WINAPI PathGetShortPathA(LPSTR lpszPath)
|
---|
220 | {
|
---|
221 | FIXME("%s stub\n", lpszPath);
|
---|
222 | return NULL;
|
---|
223 | }
|
---|
224 |
|
---|
225 | /*************************************************************************
|
---|
226 | * PathGetShortPathW [internal]
|
---|
227 | */
|
---|
228 | LPWSTR WINAPI PathGetShortPathW(LPWSTR lpszPath)
|
---|
229 | {
|
---|
230 | FIXME("%s stub\n", debugstr_w(lpszPath));
|
---|
231 | return NULL;
|
---|
232 | }
|
---|
233 |
|
---|
234 | /*************************************************************************
|
---|
235 | * PathGetShortPathAW [SHELL32.92]
|
---|
236 | */
|
---|
237 | LPVOID WINAPI PathGetShortPathAW(LPVOID lpszPath)
|
---|
238 | {
|
---|
239 | if(SHELL_OsIsUnicode())
|
---|
240 | return PathGetShortPathW(lpszPath);
|
---|
241 | return PathGetShortPathA(lpszPath);
|
---|
242 | }
|
---|
243 |
|
---|
244 | /*************************************************************************
|
---|
245 | * PathRemoveBlanksAW [SHELL32.33]
|
---|
246 | */
|
---|
247 | void WINAPI PathRemoveBlanksAW(LPVOID str)
|
---|
248 | {
|
---|
249 | if(SHELL_OsIsUnicode())
|
---|
250 | PathRemoveBlanksW(str);
|
---|
251 | PathRemoveBlanksA(str);
|
---|
252 | }
|
---|
253 |
|
---|
254 | /*************************************************************************
|
---|
255 | * PathQuoteSpacesAW [SHELL32.55]
|
---|
256 | */
|
---|
257 | LPVOID WINAPI PathQuoteSpacesAW (LPVOID lpszPath)
|
---|
258 | {
|
---|
259 | if(SHELL_OsIsUnicode())
|
---|
260 | return PathQuoteSpacesW(lpszPath);
|
---|
261 | return PathQuoteSpacesA(lpszPath);
|
---|
262 | }
|
---|
263 |
|
---|
264 | /*************************************************************************
|
---|
265 | * PathUnquoteSpacesAW [SHELL32.56]
|
---|
266 | */
|
---|
267 | VOID WINAPI PathUnquoteSpacesAW(LPVOID str)
|
---|
268 | {
|
---|
269 | if(SHELL_OsIsUnicode())
|
---|
270 | PathUnquoteSpacesW(str);
|
---|
271 | else
|
---|
272 | PathUnquoteSpacesA(str);
|
---|
273 | }
|
---|
274 |
|
---|
275 | /*************************************************************************
|
---|
276 | * PathParseIconLocationAW [SHELL32.249]
|
---|
277 | */
|
---|
278 | int WINAPI PathParseIconLocationAW (LPVOID lpszPath)
|
---|
279 | {
|
---|
280 | if(SHELL_OsIsUnicode())
|
---|
281 | return PathParseIconLocationW(lpszPath);
|
---|
282 | return PathParseIconLocationA(lpszPath);
|
---|
283 | }
|
---|
284 |
|
---|
285 | /*
|
---|
286 | ########## Path Testing ##########
|
---|
287 | */
|
---|
288 | /*************************************************************************
|
---|
289 | * PathIsUNCAW [SHELL32.39]
|
---|
290 | */
|
---|
291 | BOOL WINAPI PathIsUNCAW (LPCVOID lpszPath)
|
---|
292 | {
|
---|
293 | if (SHELL_OsIsUnicode())
|
---|
294 | return PathIsUNCW( lpszPath );
|
---|
295 | return PathIsUNCA( lpszPath );
|
---|
296 | }
|
---|
297 |
|
---|
298 | /*************************************************************************
|
---|
299 | * PathIsRelativeAW [SHELL32.40]
|
---|
300 | */
|
---|
301 | BOOL WINAPI PathIsRelativeAW (LPCVOID lpszPath)
|
---|
302 | {
|
---|
303 | if (SHELL_OsIsUnicode())
|
---|
304 | return PathIsRelativeW( lpszPath );
|
---|
305 | return PathIsRelativeA( lpszPath );
|
---|
306 | }
|
---|
307 |
|
---|
308 | /*************************************************************************
|
---|
309 | * PathIsRootAW [SHELL32.29]
|
---|
310 | */
|
---|
311 | BOOL WINAPI PathIsRootAW(LPCVOID lpszPath)
|
---|
312 | {
|
---|
313 | if (SHELL_OsIsUnicode())
|
---|
314 | return PathIsRootW(lpszPath);
|
---|
315 | return PathIsRootA(lpszPath);
|
---|
316 | }
|
---|
317 |
|
---|
318 | /*************************************************************************
|
---|
319 | * PathIsExeA [internal]
|
---|
320 | */
|
---|
321 | static BOOL PathIsExeA (LPCSTR lpszPath)
|
---|
322 | {
|
---|
323 | LPCSTR lpszExtension = PathGetExtensionA(lpszPath);
|
---|
324 | int i = 0;
|
---|
325 | static char * lpszExtensions[6] = {"exe", "com", "pid", "cmd", "bat", NULL };
|
---|
326 |
|
---|
327 | TRACE("path=%s\n",lpszPath);
|
---|
328 |
|
---|
329 | for(i=0; lpszExtensions[i]; i++)
|
---|
330 | if (!strcasecmp(lpszExtension,lpszExtensions[i])) return TRUE;
|
---|
331 |
|
---|
332 | return FALSE;
|
---|
333 | }
|
---|
334 |
|
---|
335 | /*************************************************************************
|
---|
336 | * PathIsExeW [internal]
|
---|
337 | */
|
---|
338 | static BOOL PathIsExeW (LPCWSTR lpszPath)
|
---|
339 | {
|
---|
340 | LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
|
---|
341 | int i = 0;
|
---|
342 | static WCHAR lpszExtensions[6][4] =
|
---|
343 | {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','d','\0'},
|
---|
344 | {'c','m','d','\0'}, {'b','a','t','\0'}, {'\0'} };
|
---|
345 |
|
---|
346 | TRACE("path=%s\n",debugstr_w(lpszPath));
|
---|
347 |
|
---|
348 | for(i=0; lpszExtensions[i]; i++)
|
---|
349 | if (!lstrcmpiW(lpszExtension,lpszExtensions[i])) return TRUE;
|
---|
350 |
|
---|
351 | return FALSE;
|
---|
352 | }
|
---|
353 |
|
---|
354 | /*************************************************************************
|
---|
355 | * PathIsExeAW [SHELL32.43]
|
---|
356 | */
|
---|
357 | BOOL WINAPI PathIsExeAW (LPCVOID path)
|
---|
358 | {
|
---|
359 | if (SHELL_OsIsUnicode())
|
---|
360 | return PathIsExeW (path);
|
---|
361 | return PathIsExeA(path);
|
---|
362 | }
|
---|
363 |
|
---|
364 | /*************************************************************************
|
---|
365 | * PathIsDirectoryAW [SHELL32.159]
|
---|
366 | */
|
---|
367 | BOOL WINAPI PathIsDirectoryAW (LPCVOID lpszPath)
|
---|
368 | {
|
---|
369 | if (SHELL_OsIsUnicode())
|
---|
370 | return PathIsDirectoryW (lpszPath);
|
---|
371 | return PathIsDirectoryA (lpszPath);
|
---|
372 | }
|
---|
373 |
|
---|
374 | /*************************************************************************
|
---|
375 | * PathFileExistsAW [SHELL32.45]
|
---|
376 | */
|
---|
377 | BOOL WINAPI PathFileExistsAW (LPCVOID lpszPath)
|
---|
378 | {
|
---|
379 | if (SHELL_OsIsUnicode())
|
---|
380 | return PathFileExistsW (lpszPath);
|
---|
381 | return PathFileExistsA (lpszPath);
|
---|
382 | }
|
---|
383 |
|
---|
384 | /*************************************************************************
|
---|
385 | * PathMatchSpecAW [SHELL32.46]
|
---|
386 | */
|
---|
387 | BOOL WINAPI PathMatchSpecAW(LPVOID name, LPVOID mask)
|
---|
388 | {
|
---|
389 | if (SHELL_OsIsUnicode())
|
---|
390 | return PathMatchSpecW( name, mask );
|
---|
391 | return PathMatchSpecA( name, mask );
|
---|
392 | }
|
---|
393 |
|
---|
394 | /*************************************************************************
|
---|
395 | * PathIsSameRootAW [SHELL32.650]
|
---|
396 | */
|
---|
397 | BOOL WINAPI PathIsSameRootAW(LPCVOID lpszPath1, LPCVOID lpszPath2)
|
---|
398 | {
|
---|
399 | if (SHELL_OsIsUnicode())
|
---|
400 | return PathIsSameRootW(lpszPath1, lpszPath2);
|
---|
401 | return PathIsSameRootA(lpszPath1, lpszPath2);
|
---|
402 | }
|
---|
403 |
|
---|
404 | /*************************************************************************
|
---|
405 | * IsLFNDriveA [SHELL32.119]
|
---|
406 | *
|
---|
407 | * NOTES
|
---|
408 | * exported by ordinal Name
|
---|
409 | */
|
---|
410 | BOOL WINAPI IsLFNDriveA(LPCSTR lpszPath)
|
---|
411 | {
|
---|
412 | DWORD fnlen;
|
---|
413 |
|
---|
414 | if (!GetVolumeInformationA(lpszPath,NULL,0,NULL,&fnlen,NULL,NULL,0))
|
---|
415 | return FALSE;
|
---|
416 | return fnlen>12;
|
---|
417 | }
|
---|
418 |
|
---|
419 | /*
|
---|
420 | ########## Creating Something Unique ##########
|
---|
421 | */
|
---|
422 | /*************************************************************************
|
---|
423 | * PathMakeUniqueNameA [internal]
|
---|
424 | */
|
---|
425 | BOOL WINAPI PathMakeUniqueNameA(
|
---|
426 | LPSTR lpszBuffer,
|
---|
427 | DWORD dwBuffSize,
|
---|
428 | LPCSTR lpszShortName,
|
---|
429 | LPCSTR lpszLongName,
|
---|
430 | LPCSTR lpszPathName)
|
---|
431 | {
|
---|
432 | FIXME("%p %lu %s %s %s stub\n",
|
---|
433 | lpszBuffer, dwBuffSize, debugstr_a(lpszShortName),
|
---|
434 | debugstr_a(lpszLongName), debugstr_a(lpszPathName));
|
---|
435 | return TRUE;
|
---|
436 | }
|
---|
437 |
|
---|
438 | /*************************************************************************
|
---|
439 | * PathMakeUniqueNameW [internal]
|
---|
440 | */
|
---|
441 | BOOL WINAPI PathMakeUniqueNameW(
|
---|
442 | LPWSTR lpszBuffer,
|
---|
443 | DWORD dwBuffSize,
|
---|
444 | LPCWSTR lpszShortName,
|
---|
445 | LPCWSTR lpszLongName,
|
---|
446 | LPCWSTR lpszPathName)
|
---|
447 | {
|
---|
448 | FIXME("%p %lu %s %s %s stub\n",
|
---|
449 | lpszBuffer, dwBuffSize, debugstr_w(lpszShortName),
|
---|
450 | debugstr_w(lpszLongName), debugstr_w(lpszPathName));
|
---|
451 | return TRUE;
|
---|
452 | }
|
---|
453 |
|
---|
454 | /*************************************************************************
|
---|
455 | * PathMakeUniqueNameAW [SHELL32.47]
|
---|
456 | */
|
---|
457 | BOOL WINAPI PathMakeUniqueNameAW(
|
---|
458 | LPVOID lpszBuffer,
|
---|
459 | DWORD dwBuffSize,
|
---|
460 | LPCVOID lpszShortName,
|
---|
461 | LPCVOID lpszLongName,
|
---|
462 | LPCVOID lpszPathName)
|
---|
463 | {
|
---|
464 | if (SHELL_OsIsUnicode())
|
---|
465 | return PathMakeUniqueNameW(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
|
---|
466 | return PathMakeUniqueNameA(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
|
---|
467 | }
|
---|
468 |
|
---|
469 | /*************************************************************************
|
---|
470 | * PathYetAnotherMakeUniqueNameA [SHELL32.75]
|
---|
471 | *
|
---|
472 | * NOTES
|
---|
473 | * exported by ordinal
|
---|
474 | */
|
---|
475 | BOOL WINAPI PathYetAnotherMakeUniqueNameA(
|
---|
476 | LPSTR lpszBuffer,
|
---|
477 | LPCSTR lpszPathName,
|
---|
478 | LPCSTR lpszShortName,
|
---|
479 | LPCSTR lpszLongName)
|
---|
480 | {
|
---|
481 | FIXME("(%p,%p, %p ,%p):stub.\n",
|
---|
482 | lpszBuffer, lpszPathName, lpszShortName, lpszLongName);
|
---|
483 | return TRUE;
|
---|
484 | }
|
---|
485 |
|
---|
486 | #ifdef __WIN32OS2__
|
---|
487 | /*************************************************************************
|
---|
488 | * PathYetAnotherMakeUniqueNameA [SHELL32.75]
|
---|
489 | *
|
---|
490 | * NOTES
|
---|
491 | * exported by ordinal
|
---|
492 | */
|
---|
493 | BOOL WINAPI PathYetAnotherMakeUniqueNameW(
|
---|
494 | LPWSTR lpszBuffer,
|
---|
495 | LPCWSTR lpszPathName,
|
---|
496 | LPCWSTR lpszShortName,
|
---|
497 | LPCWSTR lpszLongName)
|
---|
498 | {
|
---|
499 | FIXME("(%p,%p, %p ,%p):stub.\n",
|
---|
500 | lpszBuffer, lpszPathName, lpszShortName, lpszLongName);
|
---|
501 | return TRUE;
|
---|
502 | }
|
---|
503 |
|
---|
504 | BOOL WINAPI PathYetAnotherMakeUniqueNameAW(
|
---|
505 | LPSTR lpszBuffer,
|
---|
506 | LPCSTR lpszPathName,
|
---|
507 | LPCSTR lpszShortName,
|
---|
508 | LPCSTR lpszLongName)
|
---|
509 | {
|
---|
510 | if (SHELL_OsIsUnicode())
|
---|
511 | return PathYetAnotherMakeUniqueNameW((LPWSTR)lpszBuffer,(LPCWSTR)lpszPathName, (LPCWSTR)lpszShortName,(LPCWSTR)lpszLongName);
|
---|
512 | return PathYetAnotherMakeUniqueNameA(lpszBuffer, lpszPathName, lpszShortName,lpszLongName);
|
---|
513 | }
|
---|
514 | #endif
|
---|
515 |
|
---|
516 | /*
|
---|
517 | ########## cleaning and resolving paths ##########
|
---|
518 | */
|
---|
519 |
|
---|
520 | /*************************************************************************
|
---|
521 | * PathFindOnPathAW [SHELL32]
|
---|
522 | */
|
---|
523 | BOOL WINAPI PathFindOnPathAW(LPVOID sFile, LPCVOID sOtherDirs)
|
---|
524 | {
|
---|
525 | if (SHELL_OsIsUnicode())
|
---|
526 | return PathFindOnPathW(sFile, sOtherDirs);
|
---|
527 | return PathFindOnPathA(sFile, sOtherDirs);
|
---|
528 | }
|
---|
529 |
|
---|
530 | /*************************************************************************
|
---|
531 | * PathCleanupSpecAW [SHELL32]
|
---|
532 | */
|
---|
533 | DWORD WINAPI PathCleanupSpecAW (LPVOID x, LPVOID y)
|
---|
534 | {
|
---|
535 | FIXME("(%p, %p) stub\n",x,y);
|
---|
536 | return TRUE;
|
---|
537 | }
|
---|
538 |
|
---|
539 | /*************************************************************************
|
---|
540 | * PathQualifyA [SHELL32]
|
---|
541 | */
|
---|
542 | BOOL WINAPI PathQualifyA(LPCSTR pszPath)
|
---|
543 | {
|
---|
544 | FIXME("%s\n",pszPath);
|
---|
545 | return 0;
|
---|
546 | }
|
---|
547 |
|
---|
548 | /*************************************************************************
|
---|
549 | * PathQualifyW [SHELL32]
|
---|
550 | */
|
---|
551 | BOOL WINAPI PathQualifyW(LPCWSTR pszPath)
|
---|
552 | {
|
---|
553 | FIXME("%s\n",debugstr_w(pszPath));
|
---|
554 | return 0;
|
---|
555 | }
|
---|
556 |
|
---|
557 | /*************************************************************************
|
---|
558 | * PathQualifyAW [SHELL32]
|
---|
559 | */
|
---|
560 | BOOL WINAPI PathQualifyAW(LPCVOID pszPath)
|
---|
561 | {
|
---|
562 | if (SHELL_OsIsUnicode())
|
---|
563 | return PathQualifyW(pszPath);
|
---|
564 | return PathQualifyA(pszPath);
|
---|
565 | }
|
---|
566 |
|
---|
567 | /*************************************************************************
|
---|
568 | * PathResolveA [SHELL32.51]
|
---|
569 | */
|
---|
570 | BOOL WINAPI PathResolveA(
|
---|
571 | LPSTR lpszPath,
|
---|
572 | LPCSTR *alpszPaths,
|
---|
573 | DWORD dwFlags)
|
---|
574 | {
|
---|
575 | FIXME("(%s,%p,0x%08lx),stub!\n",
|
---|
576 | lpszPath, *alpszPaths, dwFlags);
|
---|
577 | return 0;
|
---|
578 | }
|
---|
579 |
|
---|
580 | /*************************************************************************
|
---|
581 | * PathResolveW [SHELL32]
|
---|
582 | */
|
---|
583 | BOOL WINAPI PathResolveW(
|
---|
584 | LPWSTR lpszPath,
|
---|
585 | LPCWSTR *alpszPaths,
|
---|
586 | DWORD dwFlags)
|
---|
587 | {
|
---|
588 | FIXME("(%s,%p,0x%08lx),stub!\n",
|
---|
589 | debugstr_w(lpszPath), debugstr_w(*alpszPaths), dwFlags);
|
---|
590 | return 0;
|
---|
591 | }
|
---|
592 |
|
---|
593 | /*************************************************************************
|
---|
594 | * PathResolveAW [SHELL32]
|
---|
595 | */
|
---|
596 | BOOL WINAPI PathResolveAW(
|
---|
597 | LPVOID lpszPath,
|
---|
598 | LPCVOID *alpszPaths,
|
---|
599 | DWORD dwFlags)
|
---|
600 | {
|
---|
601 | if (SHELL_OsIsUnicode())
|
---|
602 | return PathResolveW(lpszPath, (LPCWSTR*)alpszPaths, dwFlags);
|
---|
603 | return PathResolveA(lpszPath, (LPCSTR*)alpszPaths, dwFlags);
|
---|
604 | }
|
---|
605 |
|
---|
606 | /*************************************************************************
|
---|
607 | * PathProcessCommandA [SHELL32.653]
|
---|
608 | */
|
---|
609 | HRESULT WINAPI PathProcessCommandA (
|
---|
610 | LPCSTR lpszPath,
|
---|
611 | LPSTR lpszBuff,
|
---|
612 | DWORD dwBuffSize,
|
---|
613 | DWORD dwFlags)
|
---|
614 | {
|
---|
615 | FIXME("%s %p 0x%04lx 0x%04lx stub\n",
|
---|
616 | lpszPath, lpszBuff, dwBuffSize, dwFlags);
|
---|
617 | strcpy(lpszBuff, lpszPath);
|
---|
618 | return 0;
|
---|
619 | }
|
---|
620 |
|
---|
621 | /*************************************************************************
|
---|
622 | * PathProcessCommandW
|
---|
623 | */
|
---|
624 | HRESULT WINAPI PathProcessCommandW (
|
---|
625 | LPCWSTR lpszPath,
|
---|
626 | LPWSTR lpszBuff,
|
---|
627 | DWORD dwBuffSize,
|
---|
628 | DWORD dwFlags)
|
---|
629 | {
|
---|
630 | FIXME("(%s, %p, 0x%04lx, 0x%04lx) stub\n",
|
---|
631 | debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags);
|
---|
632 | strcpyW(lpszBuff, lpszPath);
|
---|
633 | return 0;
|
---|
634 | }
|
---|
635 |
|
---|
636 | /*************************************************************************
|
---|
637 | * PathProcessCommandAW
|
---|
638 | */
|
---|
639 | HRESULT WINAPI PathProcessCommandAW (
|
---|
640 | LPCVOID lpszPath,
|
---|
641 | LPVOID lpszBuff,
|
---|
642 | DWORD dwBuffSize,
|
---|
643 | DWORD dwFlags)
|
---|
644 | {
|
---|
645 | if (SHELL_OsIsUnicode())
|
---|
646 | return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags);
|
---|
647 | return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags);
|
---|
648 | }
|
---|
649 |
|
---|
650 | /*
|
---|
651 | ########## special ##########
|
---|
652 | */
|
---|
653 |
|
---|
654 | /*************************************************************************
|
---|
655 | * PathSetDlgItemPathAW
|
---|
656 | */
|
---|
657 | BOOL WINAPI PathSetDlgItemPathAW(HWND hDlg, int id, LPCVOID pszPath)
|
---|
658 | { if (SHELL_OsIsUnicode())
|
---|
659 | return PathSetDlgItemPathW(hDlg, id, pszPath);
|
---|
660 | return PathSetDlgItemPathA(hDlg, id, pszPath);
|
---|
661 | }
|
---|
662 |
|
---|
663 |
|
---|
664 | /*************************************************************************
|
---|
665 | * SHGetSpecialFolderPathA [SHELL32.175]
|
---|
666 | *
|
---|
667 | * converts csidl to path
|
---|
668 | */
|
---|
669 |
|
---|
670 | static char * szSHFolders = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
---|
671 | static char * szSHUserFolders = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
|
---|
672 | #if 0
|
---|
673 | static char * szEnvUserProfile = "%USERPROFILE%";
|
---|
674 | static char * szEnvSystemRoot = "%SYSTEMROOT%";
|
---|
675 | #endif
|
---|
676 |
|
---|
677 | BOOL WINAPI SHGetSpecialFolderPathA (
|
---|
678 | HWND hwndOwner,
|
---|
679 | LPSTR szPath,
|
---|
680 | DWORD csidl,
|
---|
681 | BOOL bCreate)
|
---|
682 | {
|
---|
683 | CHAR szValueName[MAX_PATH], szDefaultPath[MAX_PATH];
|
---|
684 | HKEY hRootKey, hKey;
|
---|
685 | BOOL bRelative = TRUE;
|
---|
686 | DWORD dwType, dwDisp, dwPathLen = MAX_PATH;
|
---|
687 |
|
---|
688 | TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner,szPath,csidl,bCreate);
|
---|
689 |
|
---|
690 | /* build default values */
|
---|
691 | switch(csidl)
|
---|
692 | {
|
---|
693 | case CSIDL_APPDATA:
|
---|
694 | hRootKey = HKEY_CURRENT_USER;
|
---|
695 | strcpy (szValueName, "AppData");
|
---|
696 | strcpy (szDefaultPath, "AppData");
|
---|
697 | break;
|
---|
698 |
|
---|
699 | case CSIDL_COOKIES:
|
---|
700 | hRootKey = HKEY_CURRENT_USER;
|
---|
701 | strcpy (szValueName, "Cookies");
|
---|
702 | strcpy(szDefaultPath, "Cookies");
|
---|
703 | break;
|
---|
704 |
|
---|
705 | case CSIDL_DESKTOPDIRECTORY:
|
---|
706 | hRootKey = HKEY_CURRENT_USER;
|
---|
707 | strcpy(szValueName, "Desktop");
|
---|
708 | strcpy(szDefaultPath, "Desktop");
|
---|
709 | break;
|
---|
710 |
|
---|
711 | case CSIDL_COMMON_DESKTOPDIRECTORY:
|
---|
712 | hRootKey = HKEY_LOCAL_MACHINE;
|
---|
713 | strcpy(szValueName, "Common Desktop");
|
---|
714 | strcpy(szDefaultPath, "Desktop");
|
---|
715 | break;
|
---|
716 |
|
---|
717 | case CSIDL_FAVORITES:
|
---|
718 | hRootKey = HKEY_CURRENT_USER;
|
---|
719 | strcpy(szValueName, "Favorites");
|
---|
720 | strcpy(szDefaultPath, "Favorites");
|
---|
721 | break;
|
---|
722 |
|
---|
723 | case CSIDL_FONTS:
|
---|
724 | hRootKey = HKEY_CURRENT_USER;
|
---|
725 | strcpy(szValueName, "Fonts");
|
---|
726 | strcpy(szDefaultPath, "Fonts");
|
---|
727 | break;
|
---|
728 |
|
---|
729 | case CSIDL_HISTORY:
|
---|
730 | hRootKey = HKEY_CURRENT_USER;
|
---|
731 | strcpy(szValueName, "History");
|
---|
732 | strcpy(szDefaultPath, "History");
|
---|
733 | break;
|
---|
734 |
|
---|
735 | case CSIDL_NETHOOD:
|
---|
736 | hRootKey = HKEY_CURRENT_USER;
|
---|
737 | strcpy(szValueName, "NetHood");
|
---|
738 | strcpy(szDefaultPath, "NetHood");
|
---|
739 | break;
|
---|
740 |
|
---|
741 | case CSIDL_INTERNET_CACHE:
|
---|
742 | hRootKey = HKEY_CURRENT_USER;
|
---|
743 | strcpy(szValueName, "Cache");
|
---|
744 | strcpy(szDefaultPath, "Temporary Internet Files");
|
---|
745 | break;
|
---|
746 |
|
---|
747 | case CSIDL_PERSONAL:
|
---|
748 | hRootKey = HKEY_CURRENT_USER;
|
---|
749 | strcpy(szValueName, "Personal");
|
---|
750 | strcpy(szDefaultPath, "My Own Files");
|
---|
751 | bRelative = FALSE;
|
---|
752 | break;
|
---|
753 |
|
---|
754 | case CSIDL_PRINTHOOD:
|
---|
755 | hRootKey = HKEY_CURRENT_USER;
|
---|
756 | strcpy(szValueName, "PrintHood");
|
---|
757 | strcpy(szDefaultPath, "PrintHood");
|
---|
758 | break;
|
---|
759 |
|
---|
760 | case CSIDL_PROGRAMS:
|
---|
761 | hRootKey = HKEY_CURRENT_USER;
|
---|
762 | strcpy(szValueName, "Programs");
|
---|
763 | strcpy(szDefaultPath, "Start Menu\\Programs");
|
---|
764 | break;
|
---|
765 |
|
---|
766 | case CSIDL_COMMON_PROGRAMS:
|
---|
767 | hRootKey = HKEY_LOCAL_MACHINE;
|
---|
768 | strcpy(szValueName, "Common Programs");
|
---|
769 | strcpy(szDefaultPath, "");
|
---|
770 | break;
|
---|
771 |
|
---|
772 | case CSIDL_RECENT:
|
---|
773 | hRootKey = HKEY_CURRENT_USER;
|
---|
774 | strcpy(szValueName, "Recent");
|
---|
775 | strcpy(szDefaultPath, "Recent");
|
---|
776 | break;
|
---|
777 |
|
---|
778 | case CSIDL_SENDTO:
|
---|
779 | hRootKey = HKEY_CURRENT_USER;
|
---|
780 | strcpy(szValueName, "SendTo");
|
---|
781 | strcpy(szDefaultPath, "SendTo");
|
---|
782 | break;
|
---|
783 |
|
---|
784 | case CSIDL_STARTMENU:
|
---|
785 | hRootKey = HKEY_CURRENT_USER;
|
---|
786 | strcpy(szValueName, "Start Menu");
|
---|
787 | strcpy(szDefaultPath, "Start Menu");
|
---|
788 | break;
|
---|
789 |
|
---|
790 | case CSIDL_COMMON_STARTMENU:
|
---|
791 | hRootKey = HKEY_LOCAL_MACHINE;
|
---|
792 | strcpy(szValueName, "Common Start Menu");
|
---|
793 | strcpy(szDefaultPath, "Start Menu");
|
---|
794 | break;
|
---|
795 |
|
---|
796 | case CSIDL_STARTUP:
|
---|
797 | hRootKey = HKEY_CURRENT_USER;
|
---|
798 | strcpy(szValueName, "StartUp");
|
---|
799 | strcpy(szDefaultPath, "Start Menu\\Programs\\StartUp");
|
---|
800 | break;
|
---|
801 |
|
---|
802 | case CSIDL_COMMON_STARTUP:
|
---|
803 | hRootKey = HKEY_LOCAL_MACHINE;
|
---|
804 | strcpy(szValueName, "Common StartUp");
|
---|
805 | strcpy(szDefaultPath, "Start Menu\\Programs\\StartUp");
|
---|
806 | break;
|
---|
807 |
|
---|
808 | case CSIDL_TEMPLATES:
|
---|
809 | hRootKey = HKEY_CURRENT_USER;
|
---|
810 | strcpy(szValueName, "Templates");
|
---|
811 | strcpy(szDefaultPath, "ShellNew");
|
---|
812 | break;
|
---|
813 |
|
---|
814 | default:
|
---|
815 | ERR("folder unknown or not allowed\n");
|
---|
816 | return FALSE;
|
---|
817 | }
|
---|
818 |
|
---|
819 | /* user shell folders */
|
---|
820 | if (RegCreateKeyExA(hRootKey,szSHUserFolders,0,NULL,0,KEY_ALL_ACCESS,NULL,&hKey,&dwDisp)) return FALSE;
|
---|
821 |
|
---|
822 | if (RegQueryValueExA(hKey,szValueName,NULL,&dwType,(LPBYTE)szPath,&dwPathLen))
|
---|
823 | {
|
---|
824 | RegCloseKey(hKey);
|
---|
825 |
|
---|
826 | /* shell folders */
|
---|
827 | if (RegCreateKeyExA(hRootKey,szSHFolders,0,NULL,0,KEY_ALL_ACCESS,NULL,&hKey,&dwDisp)) return FALSE;
|
---|
828 |
|
---|
829 | if (RegQueryValueExA(hKey,szValueName,NULL,&dwType,(LPBYTE)szPath,&dwPathLen))
|
---|
830 | {
|
---|
831 |
|
---|
832 | /* value not existing */
|
---|
833 | if (bRelative)
|
---|
834 | {
|
---|
835 | GetWindowsDirectoryA(szPath, MAX_PATH);
|
---|
836 | PathAddBackslashA(szPath);
|
---|
837 | strcat(szPath, szDefaultPath);
|
---|
838 | }
|
---|
839 | else
|
---|
840 | {
|
---|
841 | strcpy(szPath, "C:\\"); /* fixme ??? */
|
---|
842 | strcat(szPath, szDefaultPath);
|
---|
843 | }
|
---|
844 | RegSetValueExA(hKey,szValueName,0,REG_SZ,(LPBYTE)szPath,strlen(szPath)+1);
|
---|
845 | }
|
---|
846 | }
|
---|
847 | RegCloseKey(hKey);
|
---|
848 |
|
---|
849 | /* expand paths like %USERPROFILE% */
|
---|
850 | if (dwType == REG_EXPAND_SZ)
|
---|
851 | {
|
---|
852 | ExpandEnvironmentStringsA(szPath, szDefaultPath, MAX_PATH);
|
---|
853 | strcpy(szPath, szDefaultPath);
|
---|
854 | }
|
---|
855 |
|
---|
856 | /* if we don't care about existing directorys we are ready */
|
---|
857 | if(csidl & CSIDL_FLAG_DONT_VERIFY) return TRUE;
|
---|
858 |
|
---|
859 | if (PathFileExistsA(szPath)) return TRUE;
|
---|
860 |
|
---|
861 | /* not existing but we not allowed to create it */
|
---|
862 | if (!bCreate) return FALSE;
|
---|
863 |
|
---|
864 | if (!CreateDirectoryA(szPath,NULL))
|
---|
865 | {
|
---|
866 | ERR("Failed to create directory '%s'.\n", szPath);
|
---|
867 | return FALSE;
|
---|
868 | }
|
---|
869 |
|
---|
870 | MESSAGE("Created not existing system directory '%s'\n", szPath);
|
---|
871 | return TRUE;
|
---|
872 | }
|
---|
873 |
|
---|
874 | /*************************************************************************
|
---|
875 | * SHGetSpecialFolderPathW
|
---|
876 | */
|
---|
877 | BOOL WINAPI SHGetSpecialFolderPathW (
|
---|
878 | HWND hwndOwner,
|
---|
879 | LPWSTR szPath,
|
---|
880 | DWORD csidl,
|
---|
881 | BOOL bCreate)
|
---|
882 | {
|
---|
883 | char szTemp[MAX_PATH];
|
---|
884 |
|
---|
885 | if (SHGetSpecialFolderPathA(hwndOwner, szTemp, csidl, bCreate))
|
---|
886 | {
|
---|
887 | lstrcpynAtoW(szPath, szTemp, MAX_PATH);
|
---|
888 | }
|
---|
889 |
|
---|
890 | TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner,szPath,csidl,bCreate);
|
---|
891 |
|
---|
892 | return TRUE;
|
---|
893 | }
|
---|
894 |
|
---|
895 | /*************************************************************************
|
---|
896 | * SHGetSpecialFolderPathAW
|
---|
897 | */
|
---|
898 | BOOL WINAPI SHGetSpecialFolderPathAW (
|
---|
899 | HWND hwndOwner,
|
---|
900 | LPVOID szPath,
|
---|
901 | DWORD csidl,
|
---|
902 | BOOL bCreate)
|
---|
903 |
|
---|
904 | {
|
---|
905 | if (SHELL_OsIsUnicode())
|
---|
906 | return SHGetSpecialFolderPathW (hwndOwner, szPath, csidl, bCreate);
|
---|
907 | return SHGetSpecialFolderPathA (hwndOwner, szPath, csidl, bCreate);
|
---|
908 | }
|
---|
909 |
|
---|
910 | /*************************************************************************
|
---|
911 | * SHGetFolderPathA [SHFOLDER.@]
|
---|
912 | */
|
---|
913 | HRESULT WINAPI SHGetFolderPathA(
|
---|
914 | HWND hwndOwner,
|
---|
915 | int nFolder,
|
---|
916 | HANDLE hToken, /* FIXME: get paths for specific user */
|
---|
917 | DWORD dwFlags, /* FIXME: SHGFP_TYPE_CURRENT|SHGFP_TYPE_DEFAULT */
|
---|
918 | LPSTR pszPath)
|
---|
919 | {
|
---|
920 | return (SHGetSpecialFolderPathA(
|
---|
921 | hwndOwner,
|
---|
922 | pszPath,
|
---|
923 | CSIDL_FOLDER_MASK & nFolder,
|
---|
924 | CSIDL_FLAG_CREATE & nFolder )) ? S_OK : E_FAIL;
|
---|
925 | }
|
---|
926 |
|
---|
927 | /*************************************************************************
|
---|
928 | * SHGetFolderPathW [SHFOLDER.@]
|
---|
929 | */
|
---|
930 | HRESULT WINAPI SHGetFolderPathW(
|
---|
931 | HWND hwndOwner,
|
---|
932 | int nFolder,
|
---|
933 | HANDLE hToken,
|
---|
934 | DWORD dwFlags,
|
---|
935 | LPWSTR pszPath)
|
---|
936 | {
|
---|
937 | return (SHGetSpecialFolderPathW(
|
---|
938 | hwndOwner,
|
---|
939 | pszPath,
|
---|
940 | CSIDL_FOLDER_MASK & nFolder,
|
---|
941 | CSIDL_FLAG_CREATE & nFolder )) ? S_OK : E_FAIL;
|
---|
942 | }
|
---|