4 * Many of this functions are in SHLWAPI.DLL also
12 #include "winversion.h"
15 #include "shell32_main.h"
17 /*************************************************************************
18 * PathIsRoot [SHELL32.29]
20 BOOL32 WINAPI
PathIsRoot32A(LPCSTR x
)
21 { TRACE(shell
,"%s\n",x
);
22 if (*(x
+1)==':' && *(x
+2)=='\\') /* "X:\" */
24 if (*x
=='\\') /* "\" */
26 if (x
[0]=='\\' && x
[1]=='\\') /* UNC "\\<xx>\" */
27 { int foundbackslash
= 0;
33 if (foundbackslash
<=1) /* max 1 \ more ... */
38 BOOL32 WINAPI
PathIsRoot32W(LPCWSTR x
)
39 { TRACE(shell
,"%s\n",debugstr_w(x
));
40 if (*(x
+1)==':' && *(x
+2)=='\\') /* "X:\" */
42 if (*x
== (WCHAR
) '\\') /* "\" */
44 if (x
[0]==(WCHAR
)'\\' && x
[1]==(WCHAR
)'\\') /* UNC "\\<xx>\" */
45 { int foundbackslash
= 0;
48 { if (*x
++==(WCHAR
)'\\')
51 if (foundbackslash
<=1) /* max 1 \ more ... */
56 BOOL32 WINAPI
PathIsRoot32AW(LPCVOID x
)
57 { if (VERSION_OsIsUnicode())
58 return PathIsRoot32W(x
);
59 return PathIsRoot32A(x
);
62 /*************************************************************************
63 * PathBuildRoot [SHELL32.30]
65 LPSTR WINAPI
PathBuildRoot32A(LPSTR root
,BYTE drive
) {
66 TRACE(shell
,"%p %i\n",root
, drive
);
72 /*************************************************************************
73 * PathFindExtension [SHELL32.31]
76 * returns pointer to last . in last pathcomponent or at \0.
78 LPCSTR WINAPI
PathFindExtension32A(LPCSTR path
)
79 { LPCSTR lastpoint
= NULL
;
80 TRACE(shell
,"%p %s\n",path
,path
);
82 { if (*path
=='\\'||*path
==' ')
88 return lastpoint
?lastpoint
:path
;
90 LPCWSTR WINAPI
PathFindExtension32W(LPCWSTR path
)
91 { LPCWSTR lastpoint
= NULL
;
92 TRACE(shell
,"%p L%s\n",path
,debugstr_w(path
));
94 { if (*path
==(WCHAR
)'\\'||*path
==(WCHAR
)' ')
96 if (*path
==(WCHAR
)'.')
100 return lastpoint
?lastpoint
:path
;
102 LPCVOID WINAPI
PathFindExtension32AW(LPCVOID path
)
103 { if (VERSION_OsIsUnicode())
104 return PathFindExtension32W(path
);
105 return PathFindExtension32A(path
);
109 /*************************************************************************
110 * PathAddBackslash [SHELL32.32]
113 * append \ if there is none
115 LPSTR WINAPI
PathAddBackslash32A(LPSTR path
)
117 TRACE(shell
,"%p->%s\n",path
,path
);
120 if (len
&& path
[len
-1]!='\\')
127 LPWSTR WINAPI
PathAddBackslash32W(LPWSTR path
)
129 TRACE(shell
,"%p->%s\n",path
,debugstr_w(path
));
131 len
= lstrlen32W(path
);
132 if (len
&& path
[len
-1]!=(WCHAR
)'\\')
133 { path
[len
] = (WCHAR
)'\\';
139 LPVOID WINAPI
PathAddBackslash32AW(LPVOID path
)
140 { if(VERSION_OsIsUnicode())
141 return PathAddBackslash32W(path
);
142 return PathAddBackslash32A(path
);
145 /*************************************************************************
146 * PathRemoveBlanks [SHELL32.33]
149 * remove spaces from beginning and end of passed string
151 LPSTR WINAPI
PathRemoveBlanks32A(LPSTR str
)
153 TRACE(shell
,"%s\n",str
);
166 LPWSTR WINAPI
PathRemoveBlanks32W(LPWSTR str
)
168 TRACE(shell
,"%s\n",debugstr_w(str
));
174 x
=str
+lstrlen32W(str
)-1;
181 LPVOID WINAPI
PathRemoveBlanks32AW(LPVOID str
)
182 { if(VERSION_OsIsUnicode())
183 return PathRemoveBlanks32W(str
);
184 return PathRemoveBlanks32A(str
);
189 /*************************************************************************
190 * PathFindFilename [SHELL32.34]
193 * basename(char *fn);
195 LPCSTR WINAPI
PathFindFilename32A(LPCSTR aptr
)
199 TRACE(shell
,"%s\n",aslash
);
201 { if (((aptr
[0]=='\\') || (aptr
[0]==':')) && aptr
[1] && aptr
[1]!='\\')
208 LPCWSTR WINAPI
PathFindFilename32W(LPCWSTR wptr
)
212 TRACE(shell
,"L%s\n",debugstr_w(wslash
));
214 { if (((wptr
[0]=='\\') || (wptr
[0]==':')) && wptr
[1] && wptr
[1]!='\\')
220 LPCVOID WINAPI
PathFindFilename32AW(LPCVOID fn
)
222 if(VERSION_OsIsUnicode())
223 return PathFindFilename32W(fn
);
224 return PathFindFilename32A(fn
);
227 /*************************************************************************
228 * PathRemoveFileSpec [SHELL32.35]
231 * bool getpath(char *pathname); truncates passed argument to a valid path
232 * returns if the string was modified or not.
233 * "\foo\xx\foo"-> "\foo\xx"
237 DWORD WINAPI
PathRemoveFileSpec32A(LPSTR fn
) {
239 TRACE(shell
,"%s\n",fn
);
253 continue; /* already x++ed */
271 /*************************************************************************
272 * PathAppend [SHELL32.36]
275 * concat_paths(char*target,const char*add);
276 * concats "target\\add" and writes them to target
278 LPSTR WINAPI
PathAppend32A(LPSTR x1
,LPSTR x2
) {
279 TRACE(shell
,"%s %s\n",x1
,x2
);
280 while (x2
[0]=='\\') x2
++;
281 return PathCombine32A(x1
,x1
,x2
);
284 /*************************************************************************
285 * PathCombine [SHELL32.37]
288 * if lpszFile='.' skip it
289 * szDest can be equal to lpszFile. Thats why we use sTemp
291 LPSTR WINAPI
PathCombine32A(LPSTR szDest
, LPCSTR lpszDir
, LPCSTR lpszFile
)
292 { char sTemp
[MAX_PATH
];
293 TRACE(shell
,"%p %p->%s %p->%s\n",szDest
, lpszDir
, lpszDir
, lpszFile
, lpszFile
);
296 if (!lpszFile
|| !lpszFile
[0] || (lpszFile
[0]=='.' && !lpszFile
[1]) )
297 { strcpy(szDest
,lpszDir
);
301 /* if lpszFile is a complete path don't care about lpszDir */
302 if (PathIsRoot32A(lpszFile
))
303 { strcpy(szDest
,lpszFile
);
306 { strcpy(sTemp
,lpszDir
);
307 PathAddBackslash32A(sTemp
);
308 strcat(sTemp
,lpszFile
);
309 strcpy(szDest
,sTemp
);
313 LPWSTR WINAPI
PathCombine32W(LPWSTR szDest
, LPCWSTR lpszDir
, LPCWSTR lpszFile
)
314 { WCHAR sTemp
[MAX_PATH
];
315 TRACE(shell
,"%p %p->%s %p->%s\n",szDest
, lpszDir
, debugstr_w(lpszDir
),
316 lpszFile
, debugstr_w(lpszFile
));
319 if (!lpszFile
|| !lpszFile
[0] || (lpszFile
[0]==(WCHAR
)'.' && !lpszFile
[1]) )
320 { lstrcpy32W(szDest
,lpszDir
);
324 /* if lpszFile is a complete path don't care about lpszDir */
325 if (PathIsRoot32W(lpszFile
))
326 { lstrcpy32W(szDest
,lpszFile
);
329 { lstrcpy32W(sTemp
,lpszDir
);
330 PathAddBackslash32W(sTemp
);
331 lstrcat32W(sTemp
,lpszFile
);
332 lstrcpy32W(szDest
,sTemp
);
336 LPVOID WINAPI
PathCombine32AW(LPVOID szDest
, LPCVOID lpszDir
, LPCVOID lpszFile
)
337 { if (VERSION_OsIsUnicode())
338 return PathCombine32W( szDest
, lpszDir
, lpszFile
);
339 return PathCombine32A( szDest
, lpszDir
, lpszFile
);
342 /*************************************************************************
343 * PathIsUNC [SHELL32.39]
346 * PathIsUNC(char*path);
348 BOOL32 WINAPI
PathIsUNC32A(LPCSTR path
)
349 { TRACE(shell
,"%s\n",path
);
351 if ((path
[0]=='\\') && (path
[1]=='\\'))
355 BOOL32 WINAPI
PathIsUNC32W(LPCWSTR path
)
356 { TRACE(shell
,"%s\n",debugstr_w(path
));
358 if ((path
[0]=='\\') && (path
[1]=='\\'))
362 BOOL32 WINAPI
PathIsUNC32AW (LPCVOID path
)
363 { if (VERSION_OsIsUnicode())
364 return PathIsUNC32W( path
);
365 return PathIsUNC32A( path
);
367 /*************************************************************************
368 * PathIsRelativ [SHELL32.40]
371 BOOL32 WINAPI
PathIsRelative32A (LPCSTR path
)
372 { TRACE(shell
,"path=%s\n",path
);
374 if (path
&& (path
[0]!='\\' && path
[1]==':'))
378 BOOL32 WINAPI
PathIsRelative32W (LPCWSTR path
)
379 { TRACE(shell
,"path=%s\n",debugstr_w(path
));
381 if (path
&& (path
[0]!='\\' && path
[1]==':'))
385 BOOL32 WINAPI
PathIsRelative32AW (LPCVOID path
)
386 { if (VERSION_OsIsUnicode())
387 return PathIsRelative32W( path
);
388 return PathIsRelative32A( path
);
390 /*************************************************************************
391 * PathIsExe [SHELL32.43]
394 BOOL32 WINAPI
PathIsExe32A (LPCSTR path
)
395 { FIXME(shell
,"path=%s\n",path
);
398 BOOL32 WINAPI
PathIsExe32W (LPCWSTR path
)
399 { FIXME(shell
,"path=%s\n",debugstr_w(path
));
402 BOOL32 WINAPI
PathIsExe32AW (LPCVOID path
)
403 { if (VERSION_OsIsUnicode())
404 return PathIsExe32W (path
);
405 return PathIsExe32A(path
);
408 /*************************************************************************
409 * PathFileExists [SHELL32.45]
412 * file_exists(char *fn);
414 BOOL32 WINAPI
PathFileExists32A(LPSTR fn
) {
415 TRACE(shell
,"%s\n",fn
);
416 if (GetFileAttributes32A(fn
)==-1)
421 /*************************************************************************
422 * PathMatchSpec [SHELL32.46]
428 BOOL32 WINAPI
PathMatchSpec32A(LPCSTR name
, LPCSTR mask
)
431 TRACE(shell
,"%s %s stub\n",name
,mask
);
434 while (*_name
&& *mask
)
439 else if (*mask
== '*')
441 while (*mask
== '*') mask
++; /* Skip consecutive '*' */
442 if (!*mask
|| *mask
==';') return TRUE
; /* '*' matches everything */
443 while (*_name
&& (toupper(*_name
) != toupper(*mask
))) _name
++;
445 { while ( *mask
&& *mask
!= ';') mask
++;
449 else if ( (*mask
== '?') || (toupper(*mask
) == toupper(*_name
)) )
454 { while ( *mask
&& *mask
!= ';') mask
++;
457 return (!*_name
&& (!*mask
|| *mask
==';'));
459 BOOL32 WINAPI
PathMatchSpec32W(LPCWSTR name
, LPCWSTR mask
)
463 TRACE(shell
,"%s %s stub\n",debugstr_w(name
),debugstr_w(mask
));
465 lstrcpyAtoW(stemp
,"*.*");
466 if (!lstrcmp32W( mask
, stemp
)) return 1;
469 while (*_name
&& *mask
)
474 else if (*mask
== '*')
476 while (*mask
== '*') mask
++; /* Skip consecutive '*' */
477 if (!*mask
|| *mask
==';') return TRUE
; /* '*' matches everything */
478 while (*_name
&& (towupper(*_name
) != towupper(*mask
))) _name
++;
480 { while ( *mask
&& *mask
!= ';') mask
++;
484 else if ( (*mask
== '?') || (towupper(*mask
) == towupper(*_name
)) )
489 { while ( *mask
&& *mask
!= ';') mask
++;
492 return (!*_name
&& (!*mask
|| *mask
==';'));
494 BOOL32 WINAPI
PathMatchSpec32AW(LPVOID name
, LPVOID mask
)
495 { if (VERSION_OsIsUnicode())
496 return PathMatchSpec32W( name
, mask
);
497 return PathMatchSpec32A( name
, mask
);
499 /*************************************************************************
500 * PathSetDlgItemPath32AW [SHELL32.48]
502 * use PathCompactPath to make sure, the path fits into the control
505 BOOL32 WINAPI
PathSetDlgItemPath32A(HWND32 hDlg
, int id
, LPCSTR pszPath
)
506 { TRACE(shell
,"%x %x %s\n",hDlg
, id
, pszPath
);
507 return SetDlgItemText32A(hDlg
, id
, pszPath
);
509 BOOL32 WINAPI
PathSetDlgItemPath32W(HWND32 hDlg
, int id
, LPCWSTR pszPath
)
510 { TRACE(shell
,"%x %x %s\n",hDlg
, id
, debugstr_w(pszPath
));
511 return SetDlgItemText32W(hDlg
, id
, pszPath
);
513 BOOL32 WINAPI
PathSetDlgItemPath32AW(HWND32 hDlg
, int id
, LPCVOID pszPath
)
514 { if (VERSION_OsIsUnicode())
515 return PathSetDlgItemPath32W(hDlg
, id
, pszPath
);
516 return PathSetDlgItemPath32A(hDlg
, id
, pszPath
);
519 /*************************************************************************
520 * PathQualify32AW [SHELL32.49]
523 BOOL32 WINAPI
PathQualify32A(LPCSTR pszPath
)
524 { TRACE(shell
,"%s\n",pszPath
);
527 BOOL32 WINAPI
PathQualify32W(LPCWSTR pszPath
)
528 { TRACE(shell
,"%s\n",debugstr_w(pszPath
));
531 BOOL32 WINAPI
PathQualify32AW(LPCVOID pszPath
)
532 { if (VERSION_OsIsUnicode())
533 return PathQualify32W(pszPath
);
534 return PathQualify32A(pszPath
);
537 /*************************************************************************
538 * PathResolve [SHELL32.51]
540 DWORD WINAPI
PathResolve(LPCSTR s
,DWORD x2
,DWORD x3
) {
541 FIXME(shell
,"(%s,0x%08lx,0x%08lx),stub!\n",s
,x2
,x3
);
545 /*************************************************************************
546 * PathGetArgs [SHELL32.52]
549 * look for next arg in string. handle "quoted" strings
550 * returns pointer to argument *AFTER* the space. Or to the \0.
552 LPCSTR WINAPI
PathGetArgs32A(LPCSTR cmdline
)
553 { BOOL32 qflag
= FALSE
;
555 TRACE(shell
,"%s\n",cmdline
);
558 { if ((*cmdline
==' ') && !qflag
)
567 LPCWSTR WINAPI
PathGetArgs32W(LPCWSTR cmdline
)
568 { BOOL32 qflag
= FALSE
;
570 TRACE(shell
,"%sL\n",debugstr_w(cmdline
));
573 { if ((*cmdline
==' ') && !qflag
)
581 LPCVOID WINAPI
PathGetArgs32AW(LPVOID cmdline
)
582 { if (VERSION_OsIsUnicode())
583 return PathGetArgs32W(cmdline
);
584 return PathGetArgs32A(cmdline
);
586 /*************************************************************************
587 * PathQuoteSpaces [SHELL32.55]
590 * basename(char *fn);
592 LPSTR WINAPI
PathQuoteSpaces32A(LPCSTR aptr
)
593 { FIXME(shell
,"%s\n",aptr
);
597 LPWSTR WINAPI
PathQuoteSpaces32W(LPCWSTR wptr
)
598 { FIXME(shell
,"L%s\n",debugstr_w(wptr
));
601 LPVOID WINAPI
PathQuoteSpaces32AW (LPCVOID fn
)
602 { if(VERSION_OsIsUnicode())
603 return PathQuoteSpaces32W(fn
);
604 return PathQuoteSpaces32A(fn
);
608 /*************************************************************************
609 * PathUnquoteSpaces [SHELL32.56]
612 * unquote string (remove ")
614 VOID WINAPI
PathUnquoteSpaces32A(LPSTR str
)
615 { DWORD len
= lstrlen32A(str
);
616 TRACE(shell
,"%s\n",str
);
622 lstrcpy32A(str
,str
+1);
625 VOID WINAPI
PathUnquoteSpaces32W(LPWSTR str
)
626 { DWORD len
= lstrlen32W(str
);
628 TRACE(shell
,"%s\n",debugstr_w(str
));
635 lstrcpy32W(str
,str
+1);
638 VOID WINAPI
PathUnquoteSpaces32AW(LPVOID str
)
639 { if(VERSION_OsIsUnicode())
640 PathUnquoteSpaces32W(str
);
641 PathUnquoteSpaces32A(str
);
645 /*************************************************************************
646 * PathGetDriveNumber32 [SHELL32.57]
649 HRESULT WINAPI
PathGetDriveNumber32(LPSTR u
)
650 { FIXME(shell
,"%s stub\n",debugstr_a(u
));
654 /*************************************************************************
655 * PathYetAnotherMakeUniqueName [SHELL32.75]
658 * exported by ordinal
660 BOOL32 WINAPI
PathYetAnotherMakeUniqueName32A(LPDWORD x
,LPDWORD y
) {
661 FIXME(shell
,"(%p,%p):stub.\n",x
,y
);
665 /*************************************************************************
666 * IsLFNDrive [SHELL32.119]
669 * exported by ordinal Name
671 BOOL32 WINAPI
IsLFNDrive32A(LPCSTR path
) {
674 if (!GetVolumeInformation32A(path
,NULL
,0,NULL
,&fnlen
,NULL
,NULL
,0))
678 /*************************************************************************
679 * PathFindOnPath [SHELL32.145]
681 BOOL32 WINAPI
PathFindOnPath32A(LPSTR sFile
, LPCSTR sOtherDirs
)
682 { FIXME(shell
,"%s %s\n",sFile
, sOtherDirs
);
685 BOOL32 WINAPI
PathFindOnPath32W(LPWSTR sFile
, LPCWSTR sOtherDirs
)
686 { FIXME(shell
,"%s %s\n",debugstr_w(sFile
), debugstr_w(sOtherDirs
));
689 BOOL32 WINAPI
PathFindOnPath32AW(LPVOID sFile
, LPCVOID sOtherDirs
)
690 { if (VERSION_OsIsUnicode())
691 return PathFindOnPath32W(sFile
, sOtherDirs
);
692 return PathFindOnPath32A(sFile
, sOtherDirs
);
695 /*************************************************************************
696 * PathGetExtension [SHELL32.158]
699 * exported by ordinal
701 LPCSTR WINAPI
PathGetExtension32A(LPCSTR path
,DWORD y
,DWORD z
)
702 { TRACE(shell
,"(%s,%08lx,%08lx)\n",path
,y
,z
);
703 path
= PathFindExtension32A(path
);
704 return *path
?(path
+1):path
;
706 LPCWSTR WINAPI
PathGetExtension32W(LPCWSTR path
,DWORD y
,DWORD z
)
707 { TRACE(shell
,"(L%s,%08lx,%08lx)\n",debugstr_w(path
),y
,z
);
708 path
= PathFindExtension32W(path
);
709 return *path
?(path
+1):path
;
711 LPCVOID WINAPI
PathGetExtension32AW(LPCVOID path
,DWORD y
,DWORD z
)
712 { if (VERSION_OsIsUnicode())
713 return PathGetExtension32W(path
,y
,z
);
714 return PathGetExtension32A(path
,y
,z
);
717 /*************************************************************************
718 * SheGetDirW [SHELL32.281]
721 HRESULT WINAPI
SheGetDir32W(LPWSTR u
, LPWSTR v
)
722 { FIXME(shell
,"%s %s stub\n",debugstr_w(u
),debugstr_w(v
) );
726 /*************************************************************************
727 * SheChangeDirW [SHELL32.274]
730 HRESULT WINAPI
SheChangeDir32W(LPWSTR u
)
731 { FIXME(shell
,"(%s),stub\n",debugstr_w(u
));
735 /*************************************************************************
736 * PathProcessCommand [SHELL32.653]
738 HRESULT WINAPI
PathProcessCommand (DWORD u
, DWORD v
, DWORD w
, DWORD x
)
739 { FIXME(shell
,"0x%04lx 0x%04lx 0x%04lx 0x%04lx stub\n",u
,v
,w
,x
);
743 /*************************************************************************
744 * SHGetSpecialFolderPath [SHELL32.175]
746 * converts csidl to path
749 BOOL32 WINAPI
SHGetSpecialFolderPath32A (DWORD x1
,LPSTR szPath
,DWORD csidl
,DWORD x4
)
752 WARN(shell
,"(0x%04lx,%p,csidl=%lu,0x%04lx) semi-stub\n", x1
,szPath
,csidl
,x4
);
754 SHGetSpecialFolderLocation(0, csidl
, &pidl
);
755 SHGetPathFromIDList32A (pidl
, szPath
);
759 BOOL32 WINAPI
SHGetSpecialFolderPath32W (DWORD x1
,LPWSTR szPath
, DWORD csidl
,DWORD x4
)
762 WARN(shell
,"(0x%04lx,%p,csidl=%lu,0x%04lx) semi-stub\n", x1
,szPath
,csidl
,x4
);
764 SHGetSpecialFolderLocation(0, csidl
, &pidl
);
765 SHGetPathFromIDList32W (pidl
, szPath
);
769 BOOL32 WINAPI
SHGetSpecialFolderPath32 (DWORD x1
,LPVOID szPath
,DWORD csidl
,DWORD x4
)
770 { if (VERSION_OsIsUnicode())
771 return SHGetSpecialFolderPath32W ( x1
, szPath
, csidl
, x4
);
772 return SHGetSpecialFolderPath32A ( x1
, szPath
, csidl
, x4
);