source: trunk/src/shell32/new/shellpath.cpp@ 873

Last change on this file since 873 was 873, checked in by phaller, 26 years ago

.

File size: 23.5 KB
Line 
1/*
2 * Path Functions
3 *
4 * Many of this functions are in SHLWAPI.DLL also
5 *
6 */
7#include <string.h>
8#include <ctype.h>
9#include <wctype.h>
10#define HAVE_WCTYPE_H
11#include <odin.h>
12
13#define ICOM_CINTERFACE 1
14#define CINTERFACE 1
15
16#include "debugtools.h"
17#include "winnls.h"
18#include "winversion.h"
19#include "winreg.h"
20#include "crtdll.h"
21
22#include "shlobj.h"
23#include "shell32_main.h"
24
25#include <heapstring.h>
26#include <misc.h>
27
28DEFAULT_DEBUG_CHANNEL(shell)
29
30/*************************************************************************
31 * PathIsRoot [SHELL32.29]
32 */
33BOOL WINAPI PathIsRootA(LPCSTR x)
34{ TRACE("%s\n",x);
35 if (*(x+1)==':' && *(x+2)=='\\') /* "X:\" */
36 return 1;
37 if (*x=='\\') /* "\" */
38 return 0;
39 if (x[0]=='\\' && x[1]=='\\') /* UNC "\\<xx>\" */
40 { int foundbackslash = 0;
41 x=x+2;
42 while (*x)
43 { if (*x++=='\\')
44 foundbackslash++;
45 }
46 if (foundbackslash<=1) /* max 1 \ more ... */
47 return 1;
48 }
49 return 0;
50}
51BOOL WINAPI PathIsRootW(LPCWSTR x)
52{ TRACE("%s\n",debugstr_w(x));
53 if (*(x+1)==':' && *(x+2)=='\\') /* "X:\" */
54 return 1;
55 if (*x == (WCHAR) '\\') /* "\" */
56 return 0;
57 if (x[0]==(WCHAR)'\\' && x[1]==(WCHAR)'\\') /* UNC "\\<xx>\" */
58 { int foundbackslash = 0;
59 x=x+2;
60 while (*x)
61 { if (*x++==(WCHAR)'\\')
62 foundbackslash++;
63 }
64 if (foundbackslash<=1) /* max 1 \ more ... */
65 return 1;
66 }
67 return 0;
68}
69BOOL WINAPI PathIsRootAW(LPCVOID x)
70{ if (VERSION_OsIsUnicode())
71 return PathIsRootW((LPWSTR)x);
72 return PathIsRootA((LPSTR)x);
73
74}
75/*************************************************************************
76 * PathBuildRoot [SHELL32.30]
77 */
78LPSTR WINAPI PathBuildRootA(LPSTR root,BYTE drive) {
79 TRACE("%p %i\n",root, drive);
80 strcpy(root,"A:\\");
81 root[0]+=drive;
82 return root;
83}
84
85/*************************************************************************
86 * PathFindExtension [SHELL32.31]
87 *
88 * NOTES
89 * returns pointer to last . in last pathcomponent or at \0.
90 */
91LPCSTR WINAPI PathFindExtensionA(LPCSTR path)
92{ LPCSTR lastpoint = NULL;
93 TRACE("%p %s\n",path,path);
94 while (*path)
95 { if (*path=='\\'||*path==' ')
96 lastpoint=NULL;
97 if (*path=='.')
98 lastpoint=path;
99 path++;
100 }
101 return lastpoint?lastpoint:path;
102}
103LPCWSTR WINAPI PathFindExtensionW(LPCWSTR path)
104{ LPCWSTR lastpoint = NULL;
105 TRACE("%p L%s\n",path,debugstr_w(path));
106 while (*path)
107 { if (*path==(WCHAR)'\\'||*path==(WCHAR)' ')
108 lastpoint=NULL;
109 if (*path==(WCHAR)'.')
110 lastpoint=path;
111 path++;
112 }
113 return lastpoint?lastpoint:path;
114}
115LPCVOID WINAPI PathFindExtensionAW(LPCVOID path)
116{ if (VERSION_OsIsUnicode())
117 return PathFindExtensionW((LPWSTR)path);
118 return PathFindExtensionA((LPSTR)path);
119
120}
121
122/*************************************************************************
123 * PathAddBackslash [SHELL32.32]
124 *
125 * NOTES
126 * append \ if there is none
127 */
128LPSTR WINAPI PathAddBackslashA(LPSTR path)
129{ int len;
130 TRACE("%p->%s\n",path,path);
131
132 len = strlen(path);
133 if (len && path[len-1]!='\\')
134 { path[len] = '\\';
135 path[len+1]= 0x00;
136 return path+len+1;
137 }
138 return path+len;
139}
140LPWSTR WINAPI PathAddBackslashW(LPWSTR path)
141{ int len;
142 TRACE("%p->%s\n",path,debugstr_w(path));
143
144 len = lstrlenW(path);
145 if (len && path[len-1]!=(WCHAR)'\\')
146 { path[len] = (WCHAR)'\\';
147 path[len+1]= 0x00;
148 return path+len+1;
149 }
150 return path+len;
151}
152LPVOID WINAPI PathAddBackslashAW(LPVOID path)
153{ if(VERSION_OsIsUnicode())
154 return PathAddBackslashW((LPWSTR)path);
155 return PathAddBackslashA((LPSTR)path);
156}
157
158/*************************************************************************
159 * PathRemoveBlanks [SHELL32.33]
160 *
161 * NOTES
162 * remove spaces from beginning and end of passed string
163 */
164LPSTR WINAPI PathRemoveBlanksA(LPSTR str)
165{ LPSTR x = str;
166 TRACE("%s\n",str);
167 while (*x==' ') x++;
168 if (x!=str)
169 strcpy(str,x);
170 if (!*str)
171 return str;
172 x=str+strlen(str)-1;
173 while (*x==' ')
174 x--;
175 if (*x==' ')
176 *x='\0';
177 return x;
178}
179LPWSTR WINAPI PathRemoveBlanksW(LPWSTR str)
180{ LPWSTR x = str;
181 TRACE("%s\n",debugstr_w(str));
182 while (*x==' ') x++;
183 if (x!=str)
184 lstrcpyW(str,x);
185 if (!*str)
186 return str;
187 x=str+lstrlenW(str)-1;
188 while (*x==' ')
189 x--;
190 if (*x==' ')
191 *x='\0';
192 return x;
193}
194LPVOID WINAPI PathRemoveBlanksAW(LPVOID str)
195{ if(VERSION_OsIsUnicode())
196 return PathRemoveBlanksW((LPWSTR)str);
197 return PathRemoveBlanksA((LPSTR)str);
198}
199
200
201
202/*************************************************************************
203 * PathFindFilename [SHELL32.34]
204 *
205 * NOTES
206 * basename(char *fn);
207 */
208LPCSTR WINAPI PathFindFilenameA(LPCSTR aptr)
209{ LPCSTR aslash;
210 aslash = aptr;
211
212 TRACE("%s\n",aslash);
213 while (aptr[0])
214 { if (((aptr[0]=='\\') || (aptr[0]==':')) && aptr[1] && aptr[1]!='\\')
215 aslash = aptr+1;
216 aptr++;
217 }
218 return aslash;
219
220}
221LPCWSTR WINAPI PathFindFilenameW(LPCWSTR wptr)
222{ LPCWSTR wslash;
223 wslash = wptr;
224
225 TRACE("L%s\n",debugstr_w(wslash));
226 while (wptr[0])
227 { if (((wptr[0]=='\\') || (wptr[0]==':')) && wptr[1] && wptr[1]!='\\')
228 wslash = wptr+1;
229 wptr++;
230 }
231 return wslash;
232}
233LPCVOID WINAPI PathFindFilenameAW(LPCVOID fn)
234{
235 if(VERSION_OsIsUnicode())
236 return PathFindFilenameW((LPWSTR)fn);
237 return PathFindFilenameA((LPSTR)fn);
238}
239
240/*************************************************************************
241 * PathRemoveFileSpec [SHELL32.35]
242 *
243 * NOTES
244 * bool getpath(char *pathname); truncates passed argument to a valid path
245 * returns if the string was modified or not.
246 * "\foo\xx\foo"-> "\foo\xx"
247 * "\" -> "\"
248 * "a:\foo" -> "a:\"
249 */
250DWORD WINAPI PathRemoveFileSpecA(LPSTR fn) {
251 LPSTR x,cutplace;
252 TRACE("%s\n",fn);
253 if (!fn[0])
254 return 0;
255 x=fn;
256 cutplace = fn;
257 while (*x) {
258 if (*x=='\\') {
259 cutplace=x++;
260 continue;
261 }
262 if (*x==':') {
263 x++;
264 if (*x=='\\')
265 cutplace=++x;
266 continue; /* already x++ed */
267 }
268 x++;
269 }
270 if (!*cutplace)
271 return 0;
272 if (cutplace==fn) {
273 if (fn[0]=='\\') {
274 if (!fn[1])
275 return 0;
276 fn[0]='\0';
277 return 1;
278 }
279 }
280 *cutplace='\0';
281 return 1;
282}
283
284/*************************************************************************
285 * PathAppend [SHELL32.36]
286 *
287 * NOTES
288 * concat_paths(char*target,const char*add);
289 * concats "target\\add" and writes them to target
290 */
291LPSTR WINAPI PathAppendA(LPSTR x1,LPSTR x2) {
292 TRACE("%s %s\n",x1,x2);
293 while (x2[0]=='\\') x2++;
294 return PathCombineA(x1,x1,x2);
295}
296
297/*************************************************************************
298 * PathCombine [SHELL32.37]
299 *
300 * NOTES
301 * if lpszFile='.' skip it
302 * szDest can be equal to lpszFile. Thats why we use sTemp
303 */
304LPSTR WINAPI PathCombineA(LPSTR szDest, LPCSTR lpszDir, LPCSTR lpszFile)
305{ char sTemp[MAX_PATH];
306 TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, lpszDir, lpszFile, lpszFile);
307
308
309 if (!lpszFile || !lpszFile[0] || (lpszFile[0]=='.' && !lpszFile[1]) )
310 { strcpy(szDest,lpszDir);
311 return szDest;
312 }
313
314 /* if lpszFile is a complete path don't care about lpszDir */
315 if (PathIsRootA(lpszFile))
316 { strcpy(szDest,lpszFile);
317 }
318 else
319 { strcpy(sTemp,lpszDir);
320 PathAddBackslashA(sTemp);
321 strcat(sTemp,lpszFile);
322 strcpy(szDest,sTemp);
323 }
324 return szDest;
325}
326LPWSTR WINAPI PathCombineW(LPWSTR szDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
327{ WCHAR sTemp[MAX_PATH];
328 TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, debugstr_w(lpszDir),
329 lpszFile, debugstr_w(lpszFile));
330
331
332 if (!lpszFile || !lpszFile[0] || (lpszFile[0]==(WCHAR)'.' && !lpszFile[1]) )
333 { lstrcpyW(szDest,lpszDir);
334 return szDest;
335 }
336
337 /* if lpszFile is a complete path don't care about lpszDir */
338 if (PathIsRootW(lpszFile))
339 { lstrcpyW(szDest,lpszFile);
340 }
341 else
342 { lstrcpyW(sTemp,lpszDir);
343 PathAddBackslashW(sTemp);
344 lstrcatW(sTemp,lpszFile);
345 lstrcpyW(szDest,sTemp);
346 }
347 return szDest;
348}
349LPVOID WINAPI PathCombineAW(LPVOID szDest, LPCVOID lpszDir, LPCVOID lpszFile)
350{ if (VERSION_OsIsUnicode())
351 return PathCombineW( (LPWSTR)szDest, (LPWSTR)lpszDir, (LPWSTR)lpszFile );
352 return PathCombineA( (LPSTR)szDest, (LPSTR)lpszDir, (LPSTR)lpszFile );
353}
354
355/*************************************************************************
356 * PathIsUNC [SHELL32.39]
357 *
358 * NOTES
359 * PathIsUNC(char*path);
360 */
361BOOL WINAPI PathIsUNCA(LPCSTR path)
362{ TRACE("%s\n",path);
363
364 if ((path[0]=='\\') && (path[1]=='\\'))
365 return TRUE;
366 return FALSE;
367}
368BOOL WINAPI PathIsUNCW(LPCWSTR path)
369{ TRACE("%s\n",debugstr_w(path));
370
371 if ((path[0]=='\\') && (path[1]=='\\'))
372 return TRUE;
373 return FALSE;
374}
375BOOL WINAPI PathIsUNCAW (LPCVOID path)
376{ if (VERSION_OsIsUnicode())
377 return PathIsUNCW( (LPWSTR)path );
378 return PathIsUNCA( (LPSTR)path );
379}
380/*************************************************************************
381 * PathIsRelativ [SHELL32.40]
382 *
383 */
384BOOL WINAPI PathIsRelativeA (LPCSTR path)
385{ TRACE("path=%s\n",path);
386
387 if (path && (path[0]!='\\' && path[1]==':'))
388 return TRUE;
389 return FALSE;
390}
391BOOL WINAPI PathIsRelativeW (LPCWSTR path)
392{ TRACE("path=%s\n",debugstr_w(path));
393
394 if (path && (path[0]!='\\' && path[1]==':'))
395 return TRUE;
396 return FALSE;
397}
398BOOL WINAPI PathIsRelativeAW (LPCVOID path)
399{ if (VERSION_OsIsUnicode())
400 return PathIsRelativeW( (LPWSTR)path );
401 return PathIsRelativeA( (LPSTR)path );
402}
403/*************************************************************************
404 * PathIsExe [SHELL32.43]
405 *
406 */
407BOOL WINAPI PathIsExeA (LPCSTR path)
408{ FIXME("path=%s\n",path);
409 return FALSE;
410}
411BOOL WINAPI PathIsExeW (LPCWSTR path)
412{ FIXME("path=%s\n",debugstr_w(path));
413 return FALSE;
414}
415BOOL WINAPI PathIsExeAW (LPCVOID path)
416{ if (VERSION_OsIsUnicode())
417 return PathIsExeW ((LPWSTR)path);
418 return PathIsExeA((LPSTR)path);
419}
420
421/*************************************************************************
422 * PathFileExists [SHELL32.45]
423 *
424 * NOTES
425 * file_exists(char *fn);
426 */
427BOOL WINAPI PathFileExistsA(LPSTR fn) {
428 TRACE("%s\n",fn);
429 if (GetFileAttributesA(fn)==-1)
430 return FALSE;
431 else
432 return TRUE;
433}
434/*************************************************************************
435 * PathMatchSpec [SHELL32.46]
436 *
437 * NOTES
438 * used from COMDLG32
439 */
440
441BOOL WINAPI PathMatchSpecA(LPCSTR name, LPCSTR mask)
442{ LPCSTR _name;
443
444 TRACE("%s %s stub\n",name,mask);
445
446 _name = name;
447 while (*_name && *mask)
448 { if (*mask ==';')
449 { mask++;
450 _name = name;
451 }
452 else if (*mask == '*')
453 { mask++;
454 while (*mask == '*') mask++; /* Skip consecutive '*' */
455 if (!*mask || *mask==';') return TRUE; /* '*' matches everything */
456 while (*_name && (toupper(*_name) != toupper(*mask))) _name++;
457 if (!*_name)
458 { while ( *mask && *mask != ';') mask++;
459 _name = name;
460 }
461 }
462 else if ( (*mask == '?') || (toupper(*mask) == toupper(*_name)) )
463 { mask++;
464 _name++;
465 }
466 else
467 { while ( *mask && *mask != ';') mask++;
468 }
469 }
470 return (!*_name && (!*mask || *mask==';'));
471}
472BOOL WINAPI PathMatchSpecW(LPCWSTR name, LPCWSTR mask)
473{ WCHAR stemp[4];
474 LPCWSTR _name;
475
476 TRACE("%s %s stub\n",debugstr_w(name),debugstr_w(mask));
477
478 lstrcpyAtoW(stemp,"*.*");
479 if (!lstrcmpW( mask, stemp )) return 1;
480
481 _name = name;
482 while (*_name && *mask)
483 { if (*mask ==';')
484 { mask++;
485 _name = name;
486 }
487 else if (*mask == '*')
488 { mask++;
489 while (*mask == '*') mask++; /* Skip consecutive '*' */
490 if (!*mask || *mask==';') return TRUE; /* '*' matches everything */
491 while (*_name && (towupper(*_name) != towupper(*mask))) _name++;
492 if (!*_name)
493 { while ( *mask && *mask != ';') mask++;
494 _name = name;
495 }
496 }
497 else if ( (*mask == '?') || (towupper(*mask) == towupper(*_name)) )
498 { mask++;
499 _name++;
500 }
501 else
502 { while ( *mask && *mask != ';') mask++;
503 }
504 }
505 return (!*_name && (!*mask || *mask==';'));
506}
507BOOL WINAPI PathMatchSpecAW(LPVOID name, LPVOID mask)
508{ if (VERSION_OsIsUnicode())
509 return PathMatchSpecW( (LPWSTR)name, (LPWSTR)mask );
510 return PathMatchSpecA( (LPSTR)name, (LPSTR)mask );
511}
512/*************************************************************************
513 * PathSetDlgItemPathAW [SHELL32.48]
514 * NOTES
515 * use PathCompactPath to make sure, the path fits into the control
516 */
517
518BOOL WINAPI PathSetDlgItemPathA(HWND hDlg, int id, LPCSTR pszPath)
519{ TRACE("%x %x %s\n",hDlg, id, pszPath);
520 return SetDlgItemTextA(hDlg, id, pszPath);
521}
522BOOL WINAPI PathSetDlgItemPathW(HWND hDlg, int id, LPCWSTR pszPath)
523{ TRACE("%x %x %s\n",hDlg, id, debugstr_w(pszPath));
524 return SetDlgItemTextW(hDlg, id, pszPath);
525}
526BOOL WINAPI PathSetDlgItemPathAW(HWND hDlg, int id, LPCVOID pszPath)
527{ if (VERSION_OsIsUnicode())
528 return PathSetDlgItemPathW(hDlg, id, (LPWSTR)pszPath);
529 return PathSetDlgItemPathA(hDlg, id, (LPSTR)pszPath);
530}
531
532/*************************************************************************
533 * PathQualifyAW [SHELL32.49]
534 */
535
536BOOL WINAPI PathQualifyA(LPCSTR pszPath)
537{ FIXME("%s\n",pszPath);
538 return 0;
539}
540BOOL WINAPI PathQualifyW(LPCWSTR pszPath)
541{ FIXME("%s\n",debugstr_w(pszPath));
542 return 0;
543}
544BOOL WINAPI PathQualifyAW(LPCVOID pszPath)
545{ if (VERSION_OsIsUnicode())
546 return PathQualifyW((LPWSTR)pszPath);
547 return PathQualifyA((LPSTR)pszPath);
548}
549
550/*************************************************************************
551 * PathResolve [SHELL32.51]
552 */
553DWORD WINAPI PathResolve(LPCSTR s,DWORD x2,DWORD x3) {
554 FIXME("(%s,0x%08lx,0x%08lx),stub!\n",s,x2,x3);
555 return 0;
556}
557
558/*************************************************************************
559 * PathGetArgs [SHELL32.52]
560 *
561 * NOTES
562 * look for next arg in string. handle "quoted" strings
563 * returns pointer to argument *AFTER* the space. Or to the \0.
564 */
565LPCSTR WINAPI PathGetArgsA(LPCSTR cmdline)
566{ BOOL qflag = FALSE;
567
568 TRACE("%s\n",cmdline);
569
570 while (*cmdline)
571 { if ((*cmdline==' ') && !qflag)
572 return cmdline+1;
573 if (*cmdline=='"')
574 qflag=!qflag;
575 cmdline++;
576 }
577 return cmdline;
578
579}
580LPCWSTR WINAPI PathGetArgsW(LPCWSTR cmdline)
581{ BOOL qflag = FALSE;
582
583 TRACE("%sL\n",debugstr_w(cmdline));
584
585 while (*cmdline)
586 { if ((*cmdline==' ') && !qflag)
587 return cmdline+1;
588 if (*cmdline=='"')
589 qflag=!qflag;
590 cmdline++;
591 }
592 return cmdline;
593}
594LPCVOID WINAPI PathGetArgsAW(LPVOID cmdline)
595{ if (VERSION_OsIsUnicode())
596 return PathGetArgsW((LPWSTR)cmdline);
597 return PathGetArgsA((LPSTR)cmdline);
598}
599/*************************************************************************
600 * PathQuoteSpaces [SHELL32.55]
601 *
602 * NOTES
603 * basename(char *fn);
604 */
605LPSTR WINAPI PathQuoteSpacesA(LPCSTR aptr)
606{ FIXME("%s\n",aptr);
607 return 0;
608
609}
610LPWSTR WINAPI PathQuoteSpacesW(LPCWSTR wptr)
611{ FIXME("L%s\n",debugstr_w(wptr));
612 return 0;
613}
614LPVOID WINAPI PathQuoteSpacesAW (LPCVOID fn)
615{ if(VERSION_OsIsUnicode())
616 return PathQuoteSpacesW((LPWSTR)fn);
617 return PathQuoteSpacesA((LPSTR)fn);
618}
619
620
621/*************************************************************************
622 * PathUnquoteSpaces [SHELL32.56]
623 *
624 * NOTES
625 * unquote string (remove ")
626 */
627VOID WINAPI PathUnquoteSpacesA(LPSTR str)
628{ DWORD len = lstrlenA(str);
629 TRACE("%s\n",str);
630 if (*str!='"')
631 return;
632 if (str[len-1]!='"')
633 return;
634 str[len-1]='\0';
635 lstrcpyA(str,str+1);
636 return;
637}
638VOID WINAPI PathUnquoteSpacesW(LPWSTR str)
639{ DWORD len = lstrlenW(str);
640
641 TRACE("%s\n",debugstr_w(str));
642
643 if (*str!='"')
644 return;
645 if (str[len-1]!='"')
646 return;
647 str[len-1]='\0';
648 lstrcpyW(str,str+1);
649 return;
650}
651VOID WINAPI PathUnquoteSpacesAW(LPVOID str)
652{ if(VERSION_OsIsUnicode())
653 PathUnquoteSpacesW((LPWSTR)str);
654 PathUnquoteSpacesA((LPSTR)str);
655}
656
657
658/*************************************************************************
659 * PathGetDriveNumber32 [SHELL32.57]
660 *
661 */
662HRESULT WINAPI PathGetDriveNumber(LPSTR u)
663{ FIXME("%s stub\n",debugstr_a(u));
664 return 0;
665}
666
667/*************************************************************************
668 * PathYetAnotherMakeUniqueName [SHELL32.75]
669 *
670 * NOTES
671 * exported by ordinal
672 */
673BOOL WINAPI PathYetAnotherMakeUniqueNameA(LPDWORD x,LPDWORD y) {
674 FIXME("(%p,%p):stub.\n",x,y);
675 return TRUE;
676}
677
678/*************************************************************************
679 * IsLFNDrive [SHELL32.119]
680 *
681 * NOTES
682 * exported by ordinal Name
683 */
684BOOL WINAPI IsLFNDriveA(LPCSTR path) {
685 DWORD fnlen;
686
687 if (!GetVolumeInformationA(path,NULL,0,NULL,&fnlen,NULL,NULL,0))
688 return FALSE;
689 return fnlen>12;
690}
691/*************************************************************************
692 * PathFindOnPath [SHELL32.145]
693 */
694BOOL WINAPI PathFindOnPathA(LPSTR sFile, LPCSTR sOtherDirs)
695{ FIXME("%s %s\n",sFile, sOtherDirs);
696 return FALSE;
697}
698BOOL WINAPI PathFindOnPathW(LPWSTR sFile, LPCWSTR sOtherDirs)
699{ FIXME("%s %s\n",debugstr_w(sFile), debugstr_w(sOtherDirs));
700 return FALSE;
701}
702BOOL WINAPI PathFindOnPathAW(LPVOID sFile, LPCVOID sOtherDirs)
703{ if (VERSION_OsIsUnicode())
704 return PathFindOnPathW((LPWSTR)sFile, (LPWSTR)sOtherDirs);
705 return PathFindOnPathA((LPSTR)sFile, (LPSTR)sOtherDirs);
706}
707
708/*************************************************************************
709 * PathGetExtension [SHELL32.158]
710 *
711 * NOTES
712 * exported by ordinal
713 */
714LPCSTR WINAPI PathGetExtensionA(LPCSTR path,DWORD y,DWORD z)
715{ TRACE("(%s,%08lx,%08lx)\n",path,y,z);
716 path = PathFindExtensionA(path);
717 return *path?(path+1):path;
718}
719LPCWSTR WINAPI PathGetExtensionW(LPCWSTR path,DWORD y,DWORD z)
720{ TRACE("(L%s,%08lx,%08lx)\n",debugstr_w(path),y,z);
721 path = PathFindExtensionW(path);
722 return *path?(path+1):path;
723}
724LPCVOID WINAPI PathGetExtensionAW(LPCVOID path,DWORD y,DWORD z)
725{ if (VERSION_OsIsUnicode())
726 return PathGetExtensionW((LPWSTR)path,y,z);
727 return PathGetExtensionA((LPSTR)path,y,z);
728}
729
730/*************************************************************************
731 * PathCleanupSpec [SHELL32.171]
732 *
733 */
734DWORD WINAPI PathCleanupSpecA(LPSTR x, LPSTR y)
735{
736 FIXME("%p(%s) %p(%s) stub\n",x,x,y,y);
737 return TRUE;
738}
739
740DWORD WINAPI PathCleanupSpecW(LPWSTR x, LPWSTR y)
741{
742 FIXME("%p(%s) %p(%s) stub\n",x,debugstr_w(x),y,debugstr_w(y));
743 return TRUE;
744}
745
746DWORD WINAPI PathCleanupSpecAW (LPVOID x, LPVOID y)
747{
748 if (VERSION_OsIsUnicode())
749 return PathCleanupSpecW((LPWSTR)x,(LPWSTR)y);
750 return PathCleanupSpecA((LPSTR)x,(LPSTR)y);
751}
752
753/*************************************************************************
754 * SheGetDirW [SHELL32.281]
755 *
756 */
757HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v)
758{ FIXME("%p %p stub\n",u,v);
759 return 0;
760}
761
762/*************************************************************************
763 * SheChangeDirW [SHELL32.274]
764 *
765 */
766HRESULT WINAPI SheChangeDirW(LPWSTR u)
767{ FIXME("(%s),stub\n",debugstr_w(u));
768 return 0;
769}
770
771/*************************************************************************
772* PathProcessCommand [SHELL32.653]
773*/
774HRESULT WINAPI PathProcessCommandA (LPSTR lpCommand, LPSTR v, DWORD w, DWORD x)
775{
776 FIXME("%p(%s) %p 0x%04lx 0x%04lx stub\n",
777 lpCommand, lpCommand, v, w,x );
778 return 0;
779}
780
781HRESULT WINAPI PathProcessCommandW (LPWSTR lpCommand, LPSTR v, DWORD w, DWORD x)
782{
783 FIXME("%p(%s) %p 0x%04lx 0x%04lx stub\n",
784 lpCommand, debugstr_w(lpCommand), v, w,x );
785 return 0;
786}
787
788HRESULT WINAPI PathProcessCommandAW (LPVOID lpCommand, LPSTR v, DWORD w, DWORD x)
789{
790 if (VERSION_OsIsUnicode())
791 return PathProcessCommandW((LPWSTR)lpCommand, v, w, x);
792 return PathProcessCommandA((LPSTR)lpCommand, v, w, x);
793}
794
795/*************************************************************************
796 * SHGetSpecialFolderPath [SHELL32.175]
797 *
798 * converts csidl to path
799 *
800 */
801
802static char * szSHFolders = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
803
804BOOL WINAPI SHGetSpecialFolderPathA (
805 HWND hwndOwner,
806 LPSTR szPath,
807 DWORD csidl,
808 BOOL bCreate)
809{
810 CHAR szValueName[MAX_PATH], szDefaultPath[MAX_PATH];
811 HKEY hRootKey, hKey;
812 BOOL bRelative = TRUE;
813 DWORD dwType, dwDisp, dwPathLen = MAX_PATH;
814
815 TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner,szPath,csidl,bCreate);
816
817 /* build default values */
818 switch(csidl)
819 {
820 case CSIDL_APPDATA:
821 hRootKey = HKEY_CURRENT_USER;
822 strcpy (szValueName, "AppData");
823 strcpy (szDefaultPath, "AppData");
824 break;
825
826 case CSIDL_COOKIES:
827 hRootKey = HKEY_CURRENT_USER;
828 strcpy (szValueName, "Cookies");
829 strcpy(szDefaultPath, "Cookies");
830 break;
831
832 case CSIDL_DESKTOPDIRECTORY:
833 hRootKey = HKEY_CURRENT_USER;
834 strcpy(szValueName, "Desktop");
835 strcpy(szDefaultPath, "Desktop");
836 break;
837
838 case CSIDL_COMMON_DESKTOPDIRECTORY:
839 hRootKey = HKEY_LOCAL_MACHINE;
840 strcpy(szValueName, "Common Desktop");
841 strcpy(szDefaultPath, "Desktop");
842 break;
843
844 case CSIDL_FAVORITES:
845 hRootKey = HKEY_CURRENT_USER;
846 strcpy(szValueName, "Favorites");
847 strcpy(szDefaultPath, "Favorites");
848 break;
849
850 case CSIDL_FONTS:
851 hRootKey = HKEY_CURRENT_USER;
852 strcpy(szValueName, "Fonts");
853 strcpy(szDefaultPath, "Fonts");
854 break;
855
856 case CSIDL_HISTORY:
857 hRootKey = HKEY_CURRENT_USER;
858 strcpy(szValueName, "History");
859 strcpy(szDefaultPath, "History");
860 break;
861
862 case CSIDL_NETHOOD:
863 hRootKey = HKEY_CURRENT_USER;
864 strcpy(szValueName, "NetHood");
865 strcpy(szDefaultPath, "NetHood");
866 break;
867
868 case CSIDL_INTERNET_CACHE:
869 hRootKey = HKEY_CURRENT_USER;
870 strcpy(szValueName, "Cache");
871 strcpy(szDefaultPath, "Temporary Internet Files");
872 break;
873
874 case CSIDL_PERSONAL:
875 hRootKey = HKEY_CURRENT_USER;
876 strcpy(szValueName, "Personal");
877 strcpy(szDefaultPath, "My Own Files");
878 bRelative = FALSE;
879 break;
880
881 case CSIDL_PRINTHOOD:
882 hRootKey = HKEY_CURRENT_USER;
883 strcpy(szValueName, "PrintHood");
884 strcpy(szDefaultPath, "PrintHood");
885 break;
886
887 case CSIDL_PROGRAMS:
888 hRootKey = HKEY_CURRENT_USER;
889 strcpy(szValueName, "Programs");
890 strcpy(szDefaultPath, "StatrMenu\\Programs");
891 break;
892
893 case CSIDL_COMMON_PROGRAMS:
894 hRootKey = HKEY_LOCAL_MACHINE;
895 strcpy(szValueName, "Common Programs");
896 strcpy(szDefaultPath, "");
897 break;
898
899 case CSIDL_RECENT:
900 hRootKey = HKEY_CURRENT_USER;
901 strcpy(szValueName, "Recent");
902 strcpy(szDefaultPath, "Recent");
903 break;
904
905 case CSIDL_SENDTO:
906 hRootKey = HKEY_CURRENT_USER;
907 strcpy(szValueName, "SendTo");
908 strcpy(szDefaultPath, "SendTo");
909 break;
910
911 case CSIDL_STARTMENU:
912 hRootKey = HKEY_CURRENT_USER;
913 strcpy(szValueName, "StartMenu");
914 strcpy(szDefaultPath, "StartMenu");
915 break;
916
917 case CSIDL_COMMON_STARTMENU:
918 hRootKey = HKEY_LOCAL_MACHINE;
919 strcpy(szValueName, "Common StartMenu");
920 strcpy(szDefaultPath, "StartMenu");
921 break;
922
923 case CSIDL_STARTUP:
924 hRootKey = HKEY_CURRENT_USER;
925 strcpy(szValueName, "Startup");
926 strcpy(szDefaultPath, "StartMenu\\Programs\\Startup");
927 break;
928
929 case CSIDL_COMMON_STARTUP:
930 hRootKey = HKEY_LOCAL_MACHINE;
931 strcpy(szValueName, "Common Startup");
932 strcpy(szDefaultPath, "StartMenu\\Programs\\Startup");
933 break;
934
935 case CSIDL_TEMPLATES:
936 hRootKey = HKEY_CURRENT_USER;
937 strcpy(szValueName, "Templates");
938 strcpy(szDefaultPath, "ShellNew");
939 break;
940
941 default:
942 ERR("folder unknown or not allowed\n");
943 return FALSE;
944 }
945
946 if (RegCreateKeyExA(hRootKey,szSHFolders,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&hKey,&dwDisp))
947 {
948 return FALSE;
949 }
950
951 if (RegQueryValueExA(hKey,szValueName,NULL,&dwType,(LPBYTE)szPath,&dwPathLen))
952 {
953 /* value not existing */
954 if (bRelative)
955 {
956 GetWindowsDirectoryA(szPath, MAX_PATH);
957 PathAddBackslashA(szPath);
958 strcat(szPath, szDefaultPath);
959 }
960 else
961 {
962 strcpy(szPath, szDefaultPath);
963 }
964 if (bCreate)
965 {
966 CreateDirectoryA(szPath,NULL);
967 }
968 RegSetValueExA(hKey,szValueName,0,REG_SZ,(LPBYTE)szPath,strlen(szPath)+1);
969 }
970 RegCloseKey(hKey);
971
972 return TRUE;
973}
974BOOL WINAPI SHGetSpecialFolderPathW (
975 HWND hwndOwner,
976 LPWSTR szPath,
977 DWORD csidl,
978 BOOL bCreate)
979{
980 char szTemp[MAX_PATH];
981
982 if (SHGetSpecialFolderPathA(hwndOwner, szTemp, csidl, bCreate))
983 {
984 lstrcpynAtoW(szPath, szTemp, MAX_PATH);
985 }
986
987 TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner,szPath,csidl,bCreate);
988
989 return TRUE;
990}
991BOOL WINAPI SHGetSpecialFolderPathAW (
992 HWND hwndOwner,
993 LPVOID szPath,
994 DWORD csidl,
995 BOOL bCreate)
996
997{
998 if (VERSION_OsIsUnicode())
999 return SHGetSpecialFolderPathW (hwndOwner, (LPWSTR)szPath, csidl, bCreate);
1000 return SHGetSpecialFolderPathA (hwndOwner, (LPSTR)szPath, csidl, bCreate);
1001}
Note: See TracBrowser for help on using the repository browser.