4 * Many of this functions are in SHLWAPI.DLL also
11 #include "winversion.h"
14 #include "shell32_main.h"
16 /*************************************************************************
17 * PathIsRoot [SHELL32.29]
19 BOOL32 WINAPI PathIsRoot32A(LPCSTR x)
20 { TRACE(shell,"%s\n",x);
21 if (*(x+1)==':' && *(x+2)=='\\') /* "X:\" */
23 if (*x=='\\') /* "\" */
25 if (x[0]=='\\' && x[1]=='\\') /* UNC "\\<xx>\" */
26 { int foundbackslash = 0;
32 if (foundbackslash<=1) /* max 1 \ more ... */
37 BOOL32 WINAPI PathIsRoot32W(LPCWSTR x)
38 { TRACE(shell,"%s\n",debugstr_w(x));
39 if (*(x+1)==':' && *(x+2)=='\\') /* "X:\" */
41 if (*x == (WCHAR) '\\') /* "\" */
43 if (x[0]==(WCHAR)'\\' && x[1]==(WCHAR)'\\') /* UNC "\\<xx>\" */
44 { int foundbackslash = 0;
47 { if (*x++==(WCHAR)'\\')
50 if (foundbackslash<=1) /* max 1 \ more ... */
55 BOOL32 WINAPI PathIsRoot32AW(LPCVOID x)
56 { if (VERSION_OsIsUnicode())
57 return PathIsRoot32W(x);
58 return PathIsRoot32A(x);
61 /*************************************************************************
62 * PathBuildRoot [SHELL32.30]
64 LPSTR WINAPI PathBuildRoot32A(LPSTR root,BYTE drive) {
65 TRACE(shell,"%p %i\n",root, drive);
71 /*************************************************************************
72 * PathFindExtension [SHELL32.31]
75 * returns pointer to last . in last pathcomponent or at \0.
77 LPCSTR WINAPI PathFindExtension32A(LPCSTR path)
78 { LPCSTR lastpoint = NULL;
79 TRACE(shell,"%p %s\n",path,path);
81 { if (*path=='\\'||*path==' ')
87 return lastpoint?lastpoint:path;
89 LPCWSTR WINAPI PathFindExtension32W(LPCWSTR path)
90 { LPCWSTR lastpoint = NULL;
91 TRACE(shell,"%p L%s\n",path,debugstr_w(path));
93 { if (*path==(WCHAR)'\\'||*path==(WCHAR)' ')
95 if (*path==(WCHAR)'.')
99 return lastpoint?lastpoint:path;
101 LPCVOID WINAPI PathFindExtension32AW(LPCVOID path)
102 { if (VERSION_OsIsUnicode())
103 return PathFindExtension32W(path);
104 return PathFindExtension32A(path);
108 /*************************************************************************
109 * PathAddBackslash [SHELL32.32]
112 * append \ if there is none
114 LPSTR WINAPI PathAddBackslash32A(LPSTR path)
116 TRACE(shell,"%p->%s\n",path,path);
119 if (len && path[len-1]!='\\')
126 LPWSTR WINAPI PathAddBackslash32W(LPWSTR path)
128 TRACE(shell,"%p->%s\n",path,debugstr_w(path));
130 len = lstrlen32W(path);
131 if (len && path[len-1]!=(WCHAR)'\\')
132 { path[len] = (WCHAR)'\\';
138 LPVOID WINAPI PathAddBackslash32AW(LPVOID path)
139 { if(VERSION_OsIsUnicode())
140 return PathAddBackslash32W(path);
141 return PathAddBackslash32A(path);
144 /*************************************************************************
145 * PathRemoveBlanks [SHELL32.33]
148 * remove spaces from beginning and end of passed string
150 LPSTR WINAPI PathRemoveBlanks32A(LPSTR str)
152 TRACE(shell,"%s\n",str);
165 LPWSTR WINAPI PathRemoveBlanks32W(LPWSTR str)
167 TRACE(shell,"%s\n",debugstr_w(str));
173 x=str+lstrlen32W(str)-1;
180 LPVOID WINAPI PathRemoveBlanks32AW(LPVOID str)
181 { if(VERSION_OsIsUnicode())
182 return PathRemoveBlanks32W(str);
183 return PathRemoveBlanks32A(str);
188 /*************************************************************************
189 * PathFindFilename [SHELL32.34]
192 * basename(char *fn);
194 LPCSTR WINAPI PathFindFilename32A(LPCSTR aptr)
198 TRACE(shell,"%s\n",aslash);
200 { if (((aptr[0]=='\\') || (aptr[0]==':')) && aptr[1] && aptr[1]!='\\')
207 LPCWSTR WINAPI PathFindFilename32W(LPCWSTR wptr)
211 TRACE(shell,"L%s\n",debugstr_w(wslash));
213 { if (((wptr[0]=='\\') || (wptr[0]==':')) && wptr[1] && wptr[1]!='\\')
219 LPCVOID WINAPI PathFindFilename32AW(LPCVOID fn)
221 if(VERSION_OsIsUnicode())
222 return PathFindFilename32W(fn);
223 return PathFindFilename32A(fn);
226 /*************************************************************************
227 * PathRemoveFileSpec [SHELL32.35]
230 * bool getpath(char *pathname); truncates passed argument to a valid path
231 * returns if the string was modified or not.
232 * "\foo\xx\foo"-> "\foo\xx"
236 DWORD WINAPI PathRemoveFileSpec32A(LPSTR fn) {
238 TRACE(shell,"%s\n",fn);
252 continue; /* already x++ed */
270 /*************************************************************************
271 * PathAppend [SHELL32.36]
274 * concat_paths(char*target,const char*add);
275 * concats "target\\add" and writes them to target
277 LPSTR WINAPI PathAppend32A(LPSTR x1,LPSTR x2) {
278 TRACE(shell,"%s %s\n",x1,x2);
279 while (x2[0]=='\\') x2++;
280 return PathCombine32A(x1,x1,x2);
283 /*************************************************************************
284 * PathCombine [SHELL32.37]
287 * if lpszFile='.' skip it
288 * szDest can be equal to lpszFile. Thats why we use sTemp
290 LPSTR WINAPI PathCombine32A(LPSTR szDest, LPCSTR lpszDir, LPCSTR lpszFile)
291 { char sTemp[MAX_PATH];
292 TRACE(shell,"%p %p->%s %p->%s\n",szDest, lpszDir, lpszDir, lpszFile, lpszFile);
295 if (!lpszFile || !lpszFile[0] || (lpszFile[0]=='.' && !lpszFile[1]) )
296 { strcpy(szDest,lpszDir);
300 /* if lpszFile is a complete path don't care about lpszDir */
301 if (PathIsRoot32A(lpszFile))
302 { strcpy(szDest,lpszFile);
305 { strcpy(sTemp,lpszDir);
306 PathAddBackslash32A(sTemp);
307 strcat(sTemp,lpszFile);
308 strcpy(szDest,sTemp);
312 LPWSTR WINAPI PathCombine32W(LPWSTR szDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
313 { WCHAR sTemp[MAX_PATH];
314 TRACE(shell,"%p %p->%s %p->%s\n",szDest, lpszDir, debugstr_w(lpszDir),
315 lpszFile, debugstr_w(lpszFile));
318 if (!lpszFile || !lpszFile[0] || (lpszFile[0]==(WCHAR)'.' && !lpszFile[1]) )
319 { lstrcpy32W(szDest,lpszDir);
323 /* if lpszFile is a complete path don't care about lpszDir */
324 if (PathIsRoot32W(lpszFile))
325 { lstrcpy32W(szDest,lpszFile);
328 { lstrcpy32W(sTemp,lpszDir);
329 PathAddBackslash32W(sTemp);
330 lstrcat32W(sTemp,lpszFile);
331 lstrcpy32W(szDest,sTemp);
335 LPVOID WINAPI PathCombine32AW(LPVOID szDest, LPCVOID lpszDir, LPCVOID lpszFile)
336 { if (VERSION_OsIsUnicode())
337 return PathCombine32W( szDest, lpszDir, lpszFile );
338 return PathCombine32A( szDest, lpszDir, lpszFile );
341 /*************************************************************************
342 * PathIsUNC [SHELL32.39]
345 * PathIsUNC(char*path);
347 BOOL32 WINAPI PathIsUNC32A(LPCSTR path)
348 { TRACE(shell,"%s\n",path);
350 if ((path[0]=='\\') && (path[1]=='\\'))
354 BOOL32 WINAPI PathIsUNC32W(LPCWSTR path)
355 { TRACE(shell,"%s\n",debugstr_w(path));
357 if ((path[0]=='\\') && (path[1]=='\\'))
361 BOOL32 WINAPI PathIsUNC32AW (LPCVOID path)
362 { if (VERSION_OsIsUnicode())
363 return PathIsUNC32W( path );
364 return PathIsUNC32A( path );
366 /*************************************************************************
367 * PathIsRelativ [SHELL32.40]
370 BOOL32 WINAPI PathIsRelative32A (LPCSTR path)
371 { TRACE(shell,"path=%s\n",path);
373 if (path && (path[0]!='\\' && path[1]==':'))
377 BOOL32 WINAPI PathIsRelative32W (LPCWSTR path)
378 { TRACE(shell,"path=%s\n",debugstr_w(path));
380 if (path && (path[0]!='\\' && path[1]==':'))
384 BOOL32 WINAPI PathIsRelative32AW (LPCVOID path)
385 { if (VERSION_OsIsUnicode())
386 return PathIsRelative32W( path );
387 return PathIsRelative32A( path );
389 /*************************************************************************
390 * PathIsExe [SHELL32.43]
393 BOOL32 WINAPI PathIsExe32A (LPCSTR path)
394 { FIXME(shell,"path=%s\n",path);
397 BOOL32 WINAPI PathIsExe32W (LPCWSTR path)
398 { FIXME(shell,"path=%s\n",debugstr_w(path));
401 BOOL32 WINAPI PathIsExe32AW (LPCVOID path)
402 { if (VERSION_OsIsUnicode())
403 return PathIsExe32W (path);
404 return PathIsExe32A(path);
407 /*************************************************************************
408 * PathFileExists [SHELL32.45]
411 * file_exists(char *fn);
413 BOOL32 WINAPI PathFileExists32A(LPSTR fn) {
414 TRACE(shell,"%s\n",fn);
415 if (GetFileAttributes32A(fn)==-1)
420 /*************************************************************************
421 * PathMatchSpec [SHELL32.46]
427 BOOL32 WINAPI PathMatchSpec32A(LPCSTR name, LPCSTR mask)
430 TRACE(shell,"%s %s stub\n",name,mask);
433 while (*_name && *mask)
438 else if (*mask == '*')
440 while (*mask == '*') mask++; /* Skip consecutive '*' */
441 if (!*mask || *mask==';') return TRUE; /* '*' matches everything */
442 while (*_name && (toupper(*_name) != toupper(*mask))) _name++;
444 { while ( *mask && *mask != ';') mask++;
448 else if ( (*mask == '?') || (toupper(*mask) == toupper(*_name)) )
453 { while ( *mask && *mask != ';') mask++;
456 return (!*_name && (!*mask || *mask==';'));
458 BOOL32 WINAPI PathMatchSpec32W(LPCWSTR name, LPCWSTR mask)
462 TRACE(shell,"%s %s stub\n",debugstr_w(name),debugstr_w(mask));
464 lstrcpyAtoW(stemp,"*.*");
465 if (!lstrcmp32W( mask, stemp )) return 1;
468 while (*_name && *mask)
473 else if (*mask == '*')
475 while (*mask == '*') mask++; /* Skip consecutive '*' */
476 if (!*mask || *mask==';') return TRUE; /* '*' matches everything */
477 while (*_name && (towupper(*_name) != towupper(*mask))) _name++;
479 { while ( *mask && *mask != ';') mask++;
483 else if ( (*mask == '?') || (towupper(*mask) == towupper(*_name)) )
488 { while ( *mask && *mask != ';') mask++;
491 return (!*_name && (!*mask || *mask==';'));
493 BOOL32 WINAPI PathMatchSpec32AW(LPVOID name, LPVOID mask)
494 { if (VERSION_OsIsUnicode())
495 return PathMatchSpec32W( name, mask );
496 return PathMatchSpec32A( name, mask );
498 /*************************************************************************
499 * PathSetDlgItemPath32AW [SHELL32.48]
501 * use PathCompactPath to make sure, the path fits into the control
504 BOOL32 WINAPI PathSetDlgItemPath32A(HWND32 hDlg, int id, LPCSTR pszPath)
505 { TRACE(shell,"%x %x %s\n",hDlg, id, pszPath);
506 return SetDlgItemText32A(hDlg, id, pszPath);
508 BOOL32 WINAPI PathSetDlgItemPath32W(HWND32 hDlg, int id, LPCWSTR pszPath)
509 { TRACE(shell,"%x %x %s\n",hDlg, id, debugstr_w(pszPath));
510 return SetDlgItemText32W(hDlg, id, pszPath);
512 BOOL32 WINAPI PathSetDlgItemPath32AW(HWND32 hDlg, int id, LPCVOID pszPath)
513 { if (VERSION_OsIsUnicode())
514 return PathSetDlgItemPath32W(hDlg, id, pszPath);
515 return PathSetDlgItemPath32A(hDlg, id, pszPath);
518 /*************************************************************************
519 * PathQualify32AW [SHELL32.49]
522 BOOL32 WINAPI PathQualify32A(LPCSTR pszPath)
523 { TRACE(shell,"%s\n",pszPath);
526 BOOL32 WINAPI PathQualify32W(LPCWSTR pszPath)
527 { TRACE(shell,"%s\n",debugstr_w(pszPath));
530 BOOL32 WINAPI PathQualify32AW(LPCVOID pszPath)
531 { if (VERSION_OsIsUnicode())
532 return PathQualify32W(pszPath);
533 return PathQualify32A(pszPath);
536 /*************************************************************************
537 * PathResolve [SHELL32.51]
539 DWORD WINAPI PathResolve(LPCSTR s,DWORD x2,DWORD x3) {
540 FIXME(shell,"(%s,0x%08lx,0x%08lx),stub!\n",s,x2,x3);
544 /*************************************************************************
545 * PathGetArgs [SHELL32.52]
548 * look for next arg in string. handle "quoted" strings
549 * returns pointer to argument *AFTER* the space. Or to the \0.
551 LPCSTR WINAPI PathGetArgs32A(LPCSTR cmdline)
552 { BOOL32 qflag = FALSE;
554 TRACE(shell,"%s\n",cmdline);
557 { if ((*cmdline==' ') && !qflag)
566 LPCWSTR WINAPI PathGetArgs32W(LPCWSTR cmdline)
567 { BOOL32 qflag = FALSE;
569 TRACE(shell,"%sL\n",debugstr_w(cmdline));
572 { if ((*cmdline==' ') && !qflag)
580 LPCVOID WINAPI PathGetArgs32AW(LPVOID cmdline)
581 { if (VERSION_OsIsUnicode())
582 return PathGetArgs32W(cmdline);
583 return PathGetArgs32A(cmdline);
585 /*************************************************************************
586 * PathQuoteSpaces [SHELL32.55]
589 * basename(char *fn);
591 LPSTR WINAPI PathQuoteSpaces32A(LPCSTR aptr)
592 { FIXME(shell,"%s\n",aptr);
596 LPWSTR WINAPI PathQuoteSpaces32W(LPCWSTR wptr)
597 { FIXME(shell,"L%s\n",debugstr_w(wptr));
600 LPVOID WINAPI PathQuoteSpaces32AW (LPCVOID fn)
601 { if(VERSION_OsIsUnicode())
602 return PathQuoteSpaces32W(fn);
603 return PathQuoteSpaces32A(fn);
607 /*************************************************************************
608 * PathUnquoteSpaces [SHELL32.56]
611 * unquote string (remove ")
613 VOID WINAPI PathUnquoteSpaces32A(LPSTR str)
614 { DWORD len = lstrlen32A(str);
615 TRACE(shell,"%s\n",str);
621 lstrcpy32A(str,str+1);
624 VOID WINAPI PathUnquoteSpaces32W(LPWSTR str)
625 { DWORD len = lstrlen32W(str);
627 TRACE(shell,"%s\n",debugstr_w(str));
634 lstrcpy32W(str,str+1);
637 VOID WINAPI PathUnquoteSpaces32AW(LPVOID str)
638 { if(VERSION_OsIsUnicode())
639 PathUnquoteSpaces32W(str);
640 PathUnquoteSpaces32A(str);
644 /*************************************************************************
645 * PathGetDriveNumber32 [SHELL32.57]
648 HRESULT WINAPI PathGetDriveNumber32(LPSTR u)
649 { FIXME(shell,"%s stub\n",debugstr_a(u));
653 /*************************************************************************
654 * PathYetAnotherMakeUniqueName [SHELL32.75]
657 * exported by ordinal
659 BOOL32 WINAPI PathYetAnotherMakeUniqueName32A(LPDWORD x,LPDWORD y) {
660 FIXME(shell,"(%p,%p):stub.\n",x,y);
664 /*************************************************************************
665 * IsLFNDrive [SHELL32.119]
668 * exported by ordinal Name
670 BOOL32 WINAPI IsLFNDrive32A(LPCSTR path) {
673 if (!GetVolumeInformation32A(path,NULL,0,NULL,&fnlen,NULL,NULL,0))
677 /*************************************************************************
678 * PathFindOnPath [SHELL32.145]
680 BOOL32 WINAPI PathFindOnPath32A(LPSTR sFile, LPCSTR sOtherDirs)
681 { FIXME(shell,"%s %s\n",sFile, sOtherDirs);
684 BOOL32 WINAPI PathFindOnPath32W(LPWSTR sFile, LPCWSTR sOtherDirs)
685 { FIXME(shell,"%s %s\n",debugstr_w(sFile), debugstr_w(sOtherDirs));
688 BOOL32 WINAPI PathFindOnPath32AW(LPVOID sFile, LPCVOID sOtherDirs)
689 { if (VERSION_OsIsUnicode())
690 return PathFindOnPath32W(sFile, sOtherDirs);
691 return PathFindOnPath32A(sFile, sOtherDirs);
694 /*************************************************************************
695 * PathGetExtension [SHELL32.158]
698 * exported by ordinal
700 LPCSTR WINAPI PathGetExtension32A(LPCSTR path,DWORD y,DWORD z)
701 { TRACE(shell,"(%s,%08lx,%08lx)\n",path,y,z);
702 path = PathFindExtension32A(path);
703 return *path?(path+1):path;
705 LPCWSTR WINAPI PathGetExtension32W(LPCWSTR path,DWORD y,DWORD z)
706 { TRACE(shell,"(L%s,%08lx,%08lx)\n",debugstr_w(path),y,z);
707 path = PathFindExtension32W(path);
708 return *path?(path+1):path;
710 LPCVOID WINAPI PathGetExtension32AW(LPCVOID path,DWORD y,DWORD z)
711 { if (VERSION_OsIsUnicode())
712 return PathGetExtension32W(path,y,z);
713 return PathGetExtension32A(path,y,z);
716 /*************************************************************************
717 * SheGetDirW [SHELL32.281]
720 HRESULT WINAPI SheGetDir32W(LPWSTR u, LPWSTR v)
721 { FIXME(shell,"%s %s stub\n",debugstr_w(u),debugstr_w(v) );
725 /*************************************************************************
726 * SheChangeDirW [SHELL32.274]
729 HRESULT WINAPI SheChangeDir32W(LPWSTR u)
730 { FIXME(shell,"(%s),stub\n",debugstr_w(u));
734 /*************************************************************************
735 * PathProcessCommand [SHELL32.653]
737 HRESULT WINAPI PathProcessCommand (DWORD u, DWORD v, DWORD w, DWORD x)
738 { FIXME(shell,"0x%04lx 0x%04lx 0x%04lx 0x%04lx stub\n",u,v,w,x);
742 /*************************************************************************
743 * SHGetSpecialFolderPath [SHELL32.175]
745 * converts csidl to path
748 BOOL32 WINAPI SHGetSpecialFolderPath32A (DWORD x1,LPSTR szPath,DWORD csidl,DWORD x4)
751 WARN(shell,"(0x%04lx,%p,csidl=%lu,0x%04lx) semi-stub\n", x1,szPath,csidl,x4);
753 SHGetSpecialFolderLocation(0, csidl, &pidl);
754 SHGetPathFromIDList32A (pidl, szPath);
758 BOOL32 WINAPI SHGetSpecialFolderPath32W (DWORD x1,LPWSTR szPath, DWORD csidl,DWORD x4)
761 WARN(shell,"(0x%04lx,%p,csidl=%lu,0x%04lx) semi-stub\n", x1,szPath,csidl,x4);
763 SHGetSpecialFolderLocation(0, csidl, &pidl);
764 SHGetPathFromIDList32W (pidl, szPath);
768 BOOL32 WINAPI SHGetSpecialFolderPath32 (DWORD x1,LPVOID szPath,DWORD csidl,DWORD x4)
769 { if (VERSION_OsIsUnicode())
770 return SHGetSpecialFolderPath32W ( x1, szPath, csidl, x4);
771 return SHGetSpecialFolderPath32A ( x1, szPath, csidl, x4);