ReactOS 0.4.17-dev-412-gcd609f4
path.c File Reference
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include "wine/unicode.h"
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
#include "winternl.h"
#include "shlwapi.h"
#include "wine/debug.h"
Include dependency graph for path.c:

Go to the source code of this file.

Macros

#define NO_SHLWAPI_STREAM
 
#define GET_FUNC(func, module, name, fail)
 

Typedefs

typedef BOOL(WINAPIfnpIsNetDrive) (int)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
HRESULT WINAPI SHGetWebFolderFilePathW (LPCWSTR, LPWSTR, DWORD)
 
LPSTR WINAPI PathBuildRootA (LPSTR lpszPath, int drive)
 
LPWSTR WINAPI PathBuildRootW (LPWSTR lpszPath, int drive)
 
void WINAPI PathRemoveArgsA (LPSTR lpszPath)
 
void WINAPI PathRemoveArgsW (LPWSTR lpszPath)
 
BOOL WINAPI PathFileExistsDefExtW (LPWSTR lpszPath, DWORD dwWhich)
 
BOOL WINAPI PathFileExistsDefExtA (LPSTR lpszPath, DWORD dwWhich)
 
static BOOL SHLWAPI_PathFindInOtherDirs (LPWSTR lpszFile, DWORD dwWhich)
 
BOOL WINAPI PathFindOnPathExA (LPSTR lpszFile, LPCSTR *lppszOtherDirs, DWORD dwWhich)
 
BOOL WINAPI PathFindOnPathExW (LPWSTR lpszFile, LPCWSTR *lppszOtherDirs, DWORD dwWhich)
 
BOOL WINAPI PathFindOnPathA (LPSTR lpszFile, LPCSTR *lppszOtherDirs)
 
BOOL WINAPI PathFindOnPathW (LPWSTR lpszFile, LPCWSTR *lppszOtherDirs)
 
BOOL WINAPI PathCompactPathExA (LPSTR lpszDest, LPCSTR lpszPath, UINT cchMax, DWORD dwFlags)
 
BOOL WINAPI PathCompactPathExW (LPWSTR lpszDest, LPCWSTR lpszPath, UINT cchMax, DWORD dwFlags)
 
BOOL WINAPI PathIsDirectoryA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsDirectoryW (LPCWSTR lpszPath)
 
BOOL WINAPI PathFileExistsAndAttributesA (LPCSTR lpszPath, DWORD *dwAttr)
 
BOOL WINAPI PathFileExistsAndAttributesW (LPCWSTR lpszPath, DWORD *dwAttr)
 
BOOL WINAPI PathIsContentTypeA (LPCSTR path, LPCSTR content_type)
 
BOOL WINAPI PathIsContentTypeW (LPCWSTR lpszPath, LPCWSTR lpszContentType)
 
BOOL WINAPI PathIsSystemFolderA (LPCSTR lpszPath, DWORD dwAttrib)
 
BOOL WINAPI PathIsSystemFolderW (LPCWSTR lpszPath, DWORD dwAttrib)
 
BOOL WINAPI PathMakePrettyA (LPSTR lpszPath)
 
BOOL WINAPI PathMakePrettyW (LPWSTR lpszPath)
 
BOOL WINAPI PathCompactPathA (HDC hDC, LPSTR lpszPath, UINT dx)
 
BOOL WINAPI PathCompactPathW (HDC hDC, LPWSTR lpszPath, UINT dx)
 
static BOOL SHLWAPI_UseSystemForSystemFolders (void)
 
BOOL WINAPI PathMakeSystemFolderA (LPCSTR lpszPath)
 
BOOL WINAPI PathMakeSystemFolderW (LPCWSTR lpszPath)
 
BOOL WINAPI PathUnmakeSystemFolderA (LPCSTR lpszPath)
 
BOOL WINAPI PathUnmakeSystemFolderW (LPCWSTR lpszPath)
 
VOID WINAPI PathSetDlgItemPathA (HWND hDlg, int id, LPCSTR lpszPath)
 
VOID WINAPI PathSetDlgItemPathW (HWND hDlg, int id, LPCWSTR lpszPath)
 
BOOL WINAPI PathIsNetworkPathA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsNetworkPathW (LPCWSTR lpszPath)
 
BOOL WINAPI PathIsDirectoryEmptyA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsDirectoryEmptyW (LPCWSTR lpszPath)
 
LPCSTR WINAPI PathFindSuffixArrayA (LPCSTR lpszSuffix, LPCSTR *lppszArray, int dwCount)
 
LPCWSTR WINAPI PathFindSuffixArrayW (LPCWSTR lpszSuffix, LPCWSTR *lppszArray, int dwCount)
 
void WINAPI PathUndecorateA (char *path)
 
void WINAPI PathUndecorateW (WCHAR *path)
 
HRESULT WINAPI SHGetWebFolderFilePathA (LPCSTR lpszFile, LPSTR lpszPath, DWORD dwPathLen)
 

Variables

static HMODULE SHLWAPI_hshell32
 
static fnpIsNetDrive pIsNetDrive
 

Macro Definition Documentation

◆ GET_FUNC

#define GET_FUNC (   func,
  module,
  name,
  fail 
)
Value:
do { \
if (!func) { \
if (!SHLWAPI_h##module && !(SHLWAPI_h##module = LoadLibraryA(#module ".dll"))) return fail; \
func = (fn##func)GetProcAddress(SHLWAPI_h##module, name); \
if (!func) return fail; \
} \
} while (0)
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
GLenum func
Definition: glext.h:6028
Definition: name.c:39
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159

Definition at line 52 of file path.c.

◆ NO_SHLWAPI_STREAM

#define NO_SHLWAPI_STREAM

Definition at line 33 of file path.c.

Typedef Documentation

◆ fnpIsNetDrive

typedef BOOL(WINAPI * fnpIsNetDrive) (int)

Definition at line 65 of file path.c.

Function Documentation

◆ PathBuildRootA()

LPSTR WINAPI PathBuildRootA ( LPSTR  lpszPath,
int  drive 
)

Definition at line 86 of file path.c.

87{
88 TRACE("(%p,%d)\n", lpszPath, drive);
89
90 if (lpszPath && drive >= 0 && drive < 26)
91 {
92 lpszPath[0] = 'A' + drive;
93 lpszPath[1] = ':';
94 lpszPath[2] = '\\';
95 lpszPath[3] = '\0';
96 }
97 return lpszPath;
98}
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by ATL::CPathT< StringType >::PathBuildRootX(), and test_PathBuildRootA().

◆ PathBuildRootW()

LPWSTR WINAPI PathBuildRootW ( LPWSTR  lpszPath,
int  drive 
)

Definition at line 105 of file path.c.

106{
107 TRACE("(%p,%d)\n", lpszPath, drive);
108
109 if (lpszPath && drive >= 0 && drive < 26)
110 {
111 lpszPath[0] = 'A' + drive;
112 lpszPath[1] = ':';
113 lpszPath[2] = '\\';
114 lpszPath[3] = '\0';
115 }
116 return lpszPath;
117}

Referenced by IsLFNDriveW(), CDesktopBrowser::OnDeviceChange(), CDrivesFolder::ParseDisplayName(), CAddressEditBox::ParseNow(), ATL::CPathT< StringType >::PathBuildRootX(), and PathQualifyExW().

◆ PathCompactPathA()

BOOL WINAPI PathCompactPathA ( HDC  hDC,
LPSTR  lpszPath,
UINT  dx 
)

Definition at line 950 of file path.c.

951{
952 BOOL bRet = FALSE;
953
954 TRACE("(%p,%s,%d)\n", hDC, debugstr_a(lpszPath), dx);
955
956 if (lpszPath)
957 {
960 bRet = PathCompactPathW(hDC, szPath, dx);
961 WideCharToMultiByte(CP_ACP,0,szPath,-1,lpszPath,MAX_PATH,0,0);
962 }
963 return bRet;
964}
static HDC hDC
Definition: 3dtext.c:33
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define MAX_PATH
Definition: compat.h:34
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx)
Definition: path.c:971
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_a
Definition: kernel32.h:31
GLint dx
Definition: linetemp.h:97
LPCWSTR szPath
Definition: env.c:37
short WCHAR
Definition: pedump.c:58

Referenced by ATL::CPathT< StringType >::PathCompactPathX().

◆ PathCompactPathExA()

BOOL WINAPI PathCompactPathExA ( LPSTR  lpszDest,
LPCSTR  lpszPath,
UINT  cchMax,
DWORD  dwFlags 
)

Definition at line 488 of file path.c.

490{
491 BOOL bRet = FALSE;
492
493 TRACE("(%p,%s,%d,0x%08lx)\n", lpszDest, debugstr_a(lpszPath), cchMax, dwFlags);
494
495 if (lpszPath && lpszDest)
496 {
498 WCHAR szDest[MAX_PATH];
499
501 szDest[0] = '\0';
502 bRet = PathCompactPathExW(szDest, szPath, cchMax, dwFlags);
504 }
505 return bRet;
506}
UINT cchMax
WCHAR lpszDest[260]
BOOL WINAPI PathCompactPathExW(LPWSTR lpszDest, LPCWSTR lpszPath, UINT cchMax, DWORD dwFlags)
Definition: path.c:513
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141

Referenced by ATL::CPathT< StringType >::PathCompactPathExX().

◆ PathCompactPathExW()

BOOL WINAPI PathCompactPathExW ( LPWSTR  lpszDest,
LPCWSTR  lpszPath,
UINT  cchMax,
DWORD  dwFlags 
)

Definition at line 513 of file path.c.

515{
516 static const WCHAR szEllipses[] = { '.', '.', '.', '\0' };
517 LPCWSTR lpszFile;
518 DWORD dwLen, dwFileLen = 0;
519
520 TRACE("(%p,%s,%d,0x%08lx)\n", lpszDest, debugstr_w(lpszPath), cchMax, dwFlags);
521
522 if (!lpszPath)
523 return FALSE;
524
525 if (!lpszDest)
526 {
527 WARN("Invalid lpszDest would crash under Win32!\n");
528 return FALSE;
529 }
530
531 *lpszDest = '\0';
532
533 if (cchMax < 2)
534 return TRUE;
535
536 dwLen = lstrlenW(lpszPath) + 1;
537
538 if (dwLen < cchMax)
539 {
540 /* Don't need to compact */
541 memcpy(lpszDest, lpszPath, dwLen * sizeof(WCHAR));
542 return TRUE;
543 }
544
545 /* Path must be compacted to fit into lpszDest */
546 lpszFile = PathFindFileNameW(lpszPath);
547 dwFileLen = lpszPath + dwLen - lpszFile;
548
549 if (dwFileLen == dwLen)
550 {
551 /* No root in psth */
552 if (cchMax <= 4)
553 {
554 while (--cchMax > 0) /* No room left for anything but ellipses */
555 *lpszDest++ = '.';
556 *lpszDest = '\0';
557 return TRUE;
558 }
559 /* Compact the file name with ellipses at the end */
560 cchMax -= 4;
561 memcpy(lpszDest, lpszFile, cchMax * sizeof(WCHAR));
562 lstrcpyW(lpszDest + cchMax, szEllipses);
563 return TRUE;
564 }
565 /* We have a root in the path */
566 lpszFile--; /* Start compacted filename with the path separator */
567 dwFileLen++;
568
569 if (dwFileLen + 3 > cchMax)
570 {
571 /* Compact the file name */
572 if (cchMax <= 4)
573 {
574 while (--cchMax > 0) /* No room left for anything but ellipses */
575 *lpszDest++ = '.';
576 *lpszDest = '\0';
577 return TRUE;
578 }
579 lstrcpyW(lpszDest, szEllipses);
580 lpszDest += 3;
581 cchMax -= 4;
582 *lpszDest++ = *lpszFile++;
583 if (cchMax <= 4)
584 {
585 while (--cchMax > 0) /* No room left for anything but ellipses */
586 *lpszDest++ = '.';
587 *lpszDest = '\0';
588 return TRUE;
589 }
590 cchMax -= 4;
591 memcpy(lpszDest, lpszFile, cchMax * sizeof(WCHAR));
592 lstrcpyW(lpszDest + cchMax, szEllipses);
593 return TRUE;
594 }
595
596 /* Only the root needs to be Compacted */
597 dwLen = cchMax - dwFileLen - 3;
598 memcpy(lpszDest, lpszPath, dwLen * sizeof(WCHAR));
599 lstrcpyW(lpszDest + dwLen, szEllipses);
600 lstrcpyW(lpszDest + dwLen + 3, lpszFile);
601 return TRUE;
602}
#define WARN(fmt,...)
Definition: precomp.h:61
#define TRUE
Definition: types.h:120
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1677
unsigned long DWORD
Definition: ntddk_ex.h:95
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
const uint16_t * LPCWSTR
Definition: typedefs.h:57

Referenced by PathCompactPathExA(), and ATL::CPathT< StringType >::PathCompactPathExX().

◆ PathCompactPathW()

BOOL WINAPI PathCompactPathW ( HDC  hDC,
LPWSTR  lpszPath,
UINT  dx 
)

Definition at line 971 of file path.c.

972{
973 static const WCHAR szEllipses[] = { '.', '.', '.', '\0' };
974 BOOL bRet = TRUE;
975 HDC hdc = 0;
977 SIZE size;
978 DWORD dwLen;
979
980 TRACE("(%p,%s,%d)\n", hDC, debugstr_w(lpszPath), dx);
981
982 if (!lpszPath)
983 return FALSE;
984
985 if (!hDC)
986 hdc = hDC = GetDC(0);
987
988 /* Get the length of the whole path */
989 dwLen = lstrlenW(lpszPath);
990 GetTextExtentPointW(hDC, lpszPath, dwLen, &size);
991
992 if ((UINT)size.cx > dx)
993 {
994 /* Path too big, must reduce it */
995 LPWSTR sFile;
996 DWORD dwEllipsesLen = 0, dwPathLen = 0;
997
998 sFile = PathFindFileNameW(lpszPath);
999 if (sFile != lpszPath) sFile--;
1000
1001 /* Get the size of ellipses */
1002 GetTextExtentPointW(hDC, szEllipses, 3, &size);
1003 dwEllipsesLen = size.cx;
1004 /* Get the size of the file name */
1005 GetTextExtentPointW(hDC, sFile, lstrlenW(sFile), &size);
1006 dwPathLen = size.cx;
1007
1008 if (sFile != lpszPath)
1009 {
1010 LPWSTR sPath = sFile;
1011 BOOL bEllipses = FALSE;
1012
1013 /* The path includes a file name. Include as much of the path prior to
1014 * the file name as possible, allowing for the ellipses, e.g:
1015 * c:\some very long path\filename ==> c:\some v...\filename
1016 */
1017 lstrcpynW(buff, sFile, MAX_PATH);
1018
1019 do
1020 {
1021 DWORD dwTotalLen = bEllipses? dwPathLen + dwEllipsesLen : dwPathLen;
1022
1023 GetTextExtentPointW(hDC, lpszPath, sPath - lpszPath, &size);
1024 dwTotalLen += size.cx;
1025 if (dwTotalLen <= dx)
1026 break;
1027 sPath--;
1028 if (!bEllipses)
1029 {
1030 bEllipses = TRUE;
1031 sPath -= 2;
1032 }
1033 } while (sPath > lpszPath);
1034
1035 if (sPath > lpszPath)
1036 {
1037 if (bEllipses)
1038 {
1039 lstrcpyW(sPath, szEllipses);
1040 lstrcpyW(sPath+3, buff);
1041 }
1042 bRet = TRUE;
1043 goto end;
1044 }
1045 lstrcpyW(lpszPath, szEllipses);
1046 lstrcpyW(lpszPath+3, buff);
1047 bRet = FALSE;
1048 goto end;
1049 }
1050
1051 /* Trim the path by adding ellipses to the end, e.g:
1052 * A very long file name.txt ==> A very...
1053 */
1054 dwLen = lstrlenW(lpszPath);
1055
1056 if (dwLen > MAX_PATH - 3)
1057 dwLen = MAX_PATH - 3;
1058 lstrcpynW(buff, sFile, dwLen);
1059
1060 do {
1061 dwLen--;
1062 GetTextExtentPointW(hDC, buff, dwLen, &size);
1063 } while (dwLen && size.cx + dwEllipsesLen > dx);
1064
1065 if (!dwLen)
1066 {
1067 DWORD dwWritten = 0;
1068
1069 dwEllipsesLen /= 3; /* Size of a single '.' */
1070
1071 /* Write as much of the Ellipses string as possible */
1072 while (dwWritten + dwEllipsesLen < dx && dwLen < 3)
1073 {
1074 *lpszPath++ = '.';
1075 dwWritten += dwEllipsesLen;
1076 dwLen++;
1077 }
1078 *lpszPath = '\0';
1079 bRet = FALSE;
1080 }
1081 else
1082 {
1083 lstrcpyW(buff + dwLen, szEllipses);
1084 lstrcpyW(lpszPath, buff);
1085 }
1086 }
1087
1088end:
1089 if (hdc)
1090 ReleaseDC(0, hdc);
1091
1092 return bRet;
1093}
#define lstrcpynW
Definition: compat.h:738
GLuint GLuint end
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
unsigned int UINT
Definition: ndis.h:50
static const char *static const char const char DWORD void DWORD *static const char const char DWORD void DWORD *static const char DWORD DWORD void * buff
Definition: shcore.c:41
uint16_t * LPWSTR
Definition: typedefs.h:56
BOOL WINAPI GetTextExtentPointW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by CZipExtract::CCompleteSettingsPage::OnSetActive(), PathCompactPathA(), ATL::CPathT< StringType >::PathCompactPathX(), and PathSetDlgItemPathW().

◆ PathFileExistsAndAttributesA()

BOOL WINAPI PathFileExistsAndAttributesA ( LPCSTR  lpszPath,
DWORD dwAttr 
)

Definition at line 721 of file path.c.

722{
723 UINT iPrevErrMode;
724 DWORD dwVal = 0;
725
726 TRACE("(%s %p)\n", debugstr_a(lpszPath), dwAttr);
727
728 if (dwAttr)
729 *dwAttr = INVALID_FILE_ATTRIBUTES;
730
731 if (!lpszPath)
732 return FALSE;
733
734 iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
735 dwVal = GetFileAttributesA(lpszPath);
736 SetErrorMode(iPrevErrMode);
737 if (dwAttr)
738 *dwAttr = dwVal;
739 return (dwVal != INVALID_FILE_ATTRIBUTES);
740}
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:751
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:620
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

◆ PathFileExistsAndAttributesW()

BOOL WINAPI PathFileExistsAndAttributesW ( LPCWSTR  lpszPath,
DWORD dwAttr 
)

Definition at line 747 of file path.c.

748{
749 UINT iPrevErrMode;
750 DWORD dwVal;
751
752 TRACE("(%s %p)\n", debugstr_w(lpszPath), dwAttr);
753
754 if (!lpszPath)
755 return FALSE;
756
757 iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
758 dwVal = GetFileAttributesW(lpszPath);
759 SetErrorMode(iPrevErrMode);
760 if (dwAttr)
761 *dwAttr = dwVal;
762 return (dwVal != INVALID_FILE_ATTRIBUTES);
763}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636

Referenced by GetTypeDescriptionByPath(), PathFileExistsDefExtAndAttributesW(), PathResolveW(), and SHGetFileDescriptionW().

◆ PathFileExistsDefExtA()

BOOL WINAPI PathFileExistsDefExtA ( LPSTR  lpszPath,
DWORD  dwWhich 
)

Definition at line 248 of file path.c.

249{
250 BOOL bRet = FALSE;
251
252 TRACE("(%s,%ld)\n", debugstr_a(lpszPath), dwWhich);
253
254 if (lpszPath)
255 {
258 bRet = PathFileExistsDefExtW(szPath, dwWhich);
259 if (bRet)
260 WideCharToMultiByte(CP_ACP,0,szPath,-1,lpszPath,MAX_PATH,0,0);
261 }
262 return bRet;
263}
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:170

◆ PathFileExistsDefExtW()

BOOL WINAPI PathFileExistsDefExtW ( LPWSTR  lpszPath,
DWORD  dwWhich 
)

Definition at line 170 of file path.c.

171{
172 static const WCHAR pszExts[][5] = { { '.', 'p', 'i', 'f', 0},
173 { '.', 'c', 'o', 'm', 0},
174 { '.', 'e', 'x', 'e', 0},
175 { '.', 'b', 'a', 't', 0},
176 { '.', 'l', 'n', 'k', 0},
177 { '.', 'c', 'm', 'd', 0},
178 { 0, 0, 0, 0, 0} };
179
180 TRACE("(%s,%ld)\n", debugstr_w(lpszPath), dwWhich);
181
182 if (!lpszPath || PathIsUNCServerW(lpszPath) || PathIsUNCServerShareW(lpszPath))
183 return FALSE;
184
185 if (dwWhich)
186 {
187 LPCWSTR szExt = PathFindExtensionW(lpszPath);
188#ifndef __REACTOS__
189 if (!*szExt || dwWhich & 0x40)
190#else
191 if (!*szExt || dwWhich & WHICH_OPTIONAL)
192#endif
193 {
194 size_t iChoose = 0;
195 int iLen = lstrlenW(lpszPath);
196 if (iLen > (MAX_PATH - 5))
197 return FALSE;
198#ifndef __REACTOS__
199 while ( (dwWhich & 0x1) && pszExts[iChoose][0] )
200#else
201 while (pszExts[iChoose][0])
202#endif
203 {
204#ifdef __REACTOS__
205 if (dwWhich & 0x1)
206 {
208#endif
209 lstrcpyW(lpszPath + iLen, pszExts[iChoose]);
210 if (PathFileExistsW(lpszPath))
211 return TRUE;
212#ifdef __REACTOS__
213 }
214#endif
215 iChoose++;
216 dwWhich >>= 1;
217 }
218 *(lpszPath + iLen) = (WCHAR)'\0';
219 return FALSE;
220 }
221 }
222 return PathFileExistsW(lpszPath);
223}
BOOL WINAPI PathIsUNCServerShareW(const WCHAR *path)
Definition: path.c:1040
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1250
BOOL WINAPI PathIsUNCServerW(const WCHAR *path)
Definition: path.c:1852
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2583
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define WHICH_OPTIONAL
#define GetFileAttributes
Definition: winbase.h:3536

Referenced by PathFileExistsDefExtA(), PathFileExistsDefExtAndAttributesW(), PathFindOnPathExA(), PathFindOnPathExW(), PathSearchOnExtensionsW(), and SHLWAPI_PathFindInOtherDirs().

◆ PathFindOnPathA()

BOOL WINAPI PathFindOnPathA ( LPSTR  lpszFile,
LPCSTR lppszOtherDirs 
)

Definition at line 445 of file path.c.

446{
447 TRACE("(%s,%p)\n", debugstr_a(lpszFile), lppszOtherDirs);
448 return PathFindOnPathExA(lpszFile, lppszOtherDirs, 0);
449 }
BOOL WINAPI PathFindOnPathExA(LPSTR lpszFile, LPCSTR *lppszOtherDirs, DWORD dwWhich)
Definition: path.c:360

◆ PathFindOnPathExA()

BOOL WINAPI PathFindOnPathExA ( LPSTR  lpszFile,
LPCSTR lppszOtherDirs,
DWORD  dwWhich 
)

Definition at line 360 of file path.c.

361{
362 WCHAR szFile[MAX_PATH];
364
365 TRACE("(%s,%p,%08lx)\n", debugstr_a(lpszFile), lppszOtherDirs, dwWhich);
366
367 if (!lpszFile || !PathIsFileSpecA(lpszFile))
368 return FALSE;
369
370 MultiByteToWideChar(CP_ACP,0,lpszFile,-1,szFile,MAX_PATH);
371
372 /* Search provided directories first */
373 if (lppszOtherDirs && *lppszOtherDirs)
374 {
375 WCHAR szOther[MAX_PATH];
376 LPCSTR *lpszOtherPath = lppszOtherDirs;
377
378 while (lpszOtherPath && *lpszOtherPath && (*lpszOtherPath)[0])
379 {
380 MultiByteToWideChar(CP_ACP,0,*lpszOtherPath,-1,szOther,MAX_PATH);
381 PathCombineW(buff, szOther, szFile);
382 if (PathFileExistsDefExtW(buff, dwWhich))
383 {
384 WideCharToMultiByte(CP_ACP,0,buff,-1,lpszFile,MAX_PATH,0,0);
385 return TRUE;
386 }
387 lpszOtherPath++;
388 }
389 }
390 /* Not found, try system and path dirs */
391 if (SHLWAPI_PathFindInOtherDirs(szFile, dwWhich))
392 {
393 WideCharToMultiByte(CP_ACP,0,szFile,-1,lpszFile,MAX_PATH,0,0);
394 return TRUE;
395 }
396 return FALSE;
397}
BOOL WINAPI PathIsFileSpecA(const char *path)
Definition: path.c:1801
static BOOL SHLWAPI_PathFindInOtherDirs(LPWSTR lpszFile, DWORD dwWhich)
Definition: path.c:270
#define PathCombineW
Definition: pathcch.h:318
const char * LPCSTR
Definition: typedefs.h:52

Referenced by PathFindOnPathA().

◆ PathFindOnPathExW()

BOOL WINAPI PathFindOnPathExW ( LPWSTR  lpszFile,
LPCWSTR lppszOtherDirs,
DWORD  dwWhich 
)

Definition at line 404 of file path.c.

405{
407
408 TRACE("(%s,%p,%08lx)\n", debugstr_w(lpszFile), lppszOtherDirs, dwWhich);
409
410 if (!lpszFile || !PathIsFileSpecW(lpszFile))
411 return FALSE;
412
413 /* Search provided directories first */
414 if (lppszOtherDirs && *lppszOtherDirs)
415 {
416 LPCWSTR *lpszOtherPath = lppszOtherDirs;
417 while (lpszOtherPath && *lpszOtherPath && (*lpszOtherPath)[0])
418 {
419 PathCombineW(buff, *lpszOtherPath, lpszFile);
420 if (PathFileExistsDefExtW(buff, dwWhich))
421 {
422 lstrcpyW(lpszFile, buff);
423 return TRUE;
424 }
425 lpszOtherPath++;
426 }
427 }
428 /* Not found, try system and path dirs */
429 return SHLWAPI_PathFindInOtherDirs(lpszFile, dwWhich);
430}
BOOL WINAPI PathIsFileSpecW(const WCHAR *path)
Definition: path.c:1818

Referenced by PathFindOnPathW(), PathSearchOnExtensionsW(), ShellExecCmdLine(), SHEvaluateSystemCommandTemplate(), and WelcomeDlgProc().

◆ PathFindOnPathW()

BOOL WINAPI PathFindOnPathW ( LPWSTR  lpszFile,
LPCWSTR lppszOtherDirs 
)

Definition at line 456 of file path.c.

457{
458 TRACE("(%s,%p)\n", debugstr_w(lpszFile), lppszOtherDirs);
459 return PathFindOnPathExW(lpszFile,lppszOtherDirs, 0);
460}
BOOL WINAPI PathFindOnPathExW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs, DWORD dwWhich)
Definition: path.c:404

Referenced by DoEntry(), PathResolveW(), and SHELL_FindExecutable().

◆ PathFindSuffixArrayA()

LPCSTR WINAPI PathFindSuffixArrayA ( LPCSTR  lpszSuffix,
LPCSTR lppszArray,
int  dwCount 
)

Definition at line 1449 of file path.c.

1450{
1451 size_t dwLen;
1452 int dwRet = 0;
1453
1454 TRACE("(%s,%p,%d)\n",debugstr_a(lpszSuffix), lppszArray, dwCount);
1455
1456 if (lpszSuffix && lppszArray && dwCount > 0)
1457 {
1458 dwLen = strlen(lpszSuffix);
1459
1460 while (dwRet < dwCount)
1461 {
1462 size_t dwCompareLen = strlen(*lppszArray);
1463 if (dwCompareLen < dwLen)
1464 {
1465 if (!strcmp(lpszSuffix + dwLen - dwCompareLen, *lppszArray))
1466 return *lppszArray; /* Found */
1467 }
1468 dwRet++;
1469 lppszArray++;
1470 }
1471 }
1472 return NULL;
1473}
#define NULL
Definition: types.h:112
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324

◆ PathFindSuffixArrayW()

LPCWSTR WINAPI PathFindSuffixArrayW ( LPCWSTR  lpszSuffix,
LPCWSTR lppszArray,
int  dwCount 
)

Definition at line 1480 of file path.c.

1481{
1482 size_t dwLen;
1483 int dwRet = 0;
1484
1485 TRACE("(%s,%p,%d)\n",debugstr_w(lpszSuffix), lppszArray, dwCount);
1486
1487 if (lpszSuffix && lppszArray && dwCount > 0)
1488 {
1489 dwLen = lstrlenW(lpszSuffix);
1490
1491 while (dwRet < dwCount)
1492 {
1493 size_t dwCompareLen = lstrlenW(*lppszArray);
1494 if (dwCompareLen < dwLen)
1495 {
1496 if (!wcscmp(lpszSuffix + dwLen - dwCompareLen, *lppszArray))
1497 return *lppszArray; /* Found */
1498 }
1499 dwRet++;
1500 lppszArray++;
1501 }
1502 }
1503 return NULL;
1504}
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977

◆ PathIsContentTypeA()

BOOL WINAPI PathIsContentTypeA ( LPCSTR  path,
LPCSTR  content_type 
)

Definition at line 783 of file path.c.

784{
785 char buf[MAX_PATH];
786 DWORD size = sizeof(buf);
787 LPCSTR ext;
788
790
791 if(!path) return FALSE;
792 if(!(ext = PathFindExtensionA(path)) || !*ext) return FALSE;
793 if(SHGetValueA(HKEY_CLASSES_ROOT, ext, "Content Type", NULL, buf, &size)) return FALSE;
794 return !lstrcmpiA(content_type, buf);
795}
static const WCHAR *const ext[]
Definition: module.c:53
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
LPSTR WINAPI PathFindExtensionA(const char *path)
Definition: path.c:1229
DWORD WINAPI SHGetValueA(HKEY hkey, const char *subkey, const char *value, DWORD *type, void *data, DWORD *data_len)
Definition: main.c:2197
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static BSTR content_type
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

◆ PathIsContentTypeW()

BOOL WINAPI PathIsContentTypeW ( LPCWSTR  lpszPath,
LPCWSTR  lpszContentType 
)

Definition at line 802 of file path.c.

803{
804 static const WCHAR szContentType[] = { 'C','o','n','t','e','n','t',' ','T','y','p','e','\0' };
805 LPCWSTR szExt;
806 DWORD dwDummy;
807 WCHAR szBuff[MAX_PATH];
808
809 TRACE("(%s,%s)\n", debugstr_w(lpszPath), debugstr_w(lpszContentType));
810
811 if (lpszPath && (szExt = PathFindExtensionW(lpszPath)) && *szExt &&
812 !SHGetValueW(HKEY_CLASSES_ROOT, szExt, szContentType,
813 REG_NONE, szBuff, &dwDummy) &&
814 !wcsicmp(lpszContentType, szBuff))
815 {
816 return TRUE;
817 }
818 return FALSE;
819}
#define wcsicmp
Definition: compat.h:15
DWORD WINAPI SHGetValueW(HKEY hkey, const WCHAR *subkey, const WCHAR *value, DWORD *type, void *data, DWORD *data_len)
Definition: main.c:2222
#define REG_NONE
Definition: nt_native.h:1495

◆ PathIsDirectoryA()

BOOL WINAPI PathIsDirectoryA ( LPCSTR  lpszPath)

Definition at line 625 of file path.c.

626{
627 DWORD dwAttr;
628
629 TRACE("(%s)\n", debugstr_a(lpszPath));
630
631 if (!lpszPath || PathIsUNCServerA(lpszPath))
632 return FALSE;
633
634 if (PathIsUNCServerShareA(lpszPath))
635 {
636#ifdef __REACTOS__
637 LPSTR lpSystem = NULL;
638 BYTE buffer[512] = {0};
639 DWORD cbBuffer = sizeof(buffer);
641 DWORD dwError;
642
643 pNetRes->dwScope = RESOURCE_GLOBALNET;
644 pNetRes->dwType = RESOURCETYPE_ANY;
645 pNetRes->lpRemoteName = (LPSTR)lpszPath;
646
647 dwError = WNetGetResourceInformationA(pNetRes, pNetRes, &cbBuffer, &lpSystem);
648 if (dwError == NO_ERROR && pNetRes->dwDisplayType != RESOURCEDISPLAYTYPE_GENERIC)
649 {
650 return (pNetRes->dwDisplayType == RESOURCEDISPLAYTYPE_SHARE) &&
651 (pNetRes->dwType == RESOURCETYPE_ANY || pNetRes->dwType == RESOURCETYPE_DISK);
652 }
653#else
654 FIXME("UNC Server Share not yet supported - FAILING\n");
655 return FALSE;
656#endif
657 }
658
659 if ((dwAttr = GetFileAttributesA(lpszPath)) == INVALID_FILE_ATTRIBUTES)
660 return FALSE;
661 return dwAttr & FILE_ATTRIBUTE_DIRECTORY;
662}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define NO_ERROR
Definition: dderror.h:5
BOOL WINAPI PathIsUNCServerA(const char *path)
Definition: path.c:1835
BOOL WINAPI PathIsUNCServerShareA(const char *path)
Definition: path.c:1016
GLuint buffer
Definition: glext.h:5915
DWORD dwDisplayType
Definition: winnetwk.h:169
DWORD dwScope
Definition: winnetwk.h:167
LPSTR lpRemoteName
Definition: winnetwk.h:172
DWORD dwType
Definition: winnetwk.h:168
char * LPSTR
Definition: typedefs.h:51
struct _NETRESOURCEA * LPNETRESOURCEA
#define RESOURCEDISPLAYTYPE_SHARE
Definition: winnetwk.h:78
#define RESOURCEDISPLAYTYPE_GENERIC
Definition: winnetwk.h:75
#define RESOURCETYPE_DISK
Definition: winnetwk.h:64
#define RESOURCETYPE_ANY
Definition: winnetwk.h:63
#define RESOURCE_GLOBALNET
Definition: winnetwk.h:59
DWORD WINAPI WNetGetResourceInformationA(LPNETRESOURCEA lpNetResource, LPVOID lpBuffer, LPDWORD cbBuffer, LPSTR *lplpSystem)
Definition: wnet.c:1822
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ATL::CPathT< StringType >::PathIsDirectoryX().

◆ PathIsDirectoryEmptyA()

BOOL WINAPI PathIsDirectoryEmptyA ( LPCSTR  lpszPath)

Definition at line 1367 of file path.c.

1368{
1369 BOOL bRet = FALSE;
1370
1371 TRACE("(%s)\n",debugstr_a(lpszPath));
1372
1373 if (lpszPath)
1374 {
1378 }
1379 return bRet;
1380}
BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath)
Definition: path.c:1387

◆ PathIsDirectoryEmptyW()

BOOL WINAPI PathIsDirectoryEmptyW ( LPCWSTR  lpszPath)

Definition at line 1387 of file path.c.

1388{
1389 static const WCHAR szAllFiles[] = { '*', '.', '*', '\0' };
1390 WCHAR szSearch[MAX_PATH];
1391 DWORD dwLen;
1392 HANDLE hfind;
1393 BOOL retVal = TRUE;
1395
1396 TRACE("(%s)\n",debugstr_w(lpszPath));
1397
1398 if (!lpszPath || !PathIsDirectoryW(lpszPath))
1399 return FALSE;
1400
1401 lstrcpynW(szSearch, lpszPath, MAX_PATH);
1402 PathAddBackslashW(szSearch);
1403 dwLen = lstrlenW(szSearch);
1404 if (dwLen > MAX_PATH - 4)
1405 return FALSE;
1406
1407 lstrcpyW(szSearch + dwLen, szAllFiles);
1408 hfind = FindFirstFileW(szSearch, &find_data);
1409 if (hfind == INVALID_HANDLE_VALUE)
1410 return FALSE;
1411
1412 do
1413 {
1414 if (find_data.cFileName[0] == '.')
1415 {
1416 if (find_data.cFileName[1] == '\0') continue;
1417 if (find_data.cFileName[1] == '.' && find_data.cFileName[2] == '\0') continue;
1418 }
1419
1420 retVal = FALSE;
1421 break;
1422 }
1423 while (FindNextFileW(hfind, &find_data));
1424
1425 FindClose(hfind);
1426 return retVal;
1427}
static int find_data(const struct Vector *v, const BYTE *pData, int size)
Definition: filtermapper.c:162
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:669
#define PathAddBackslashW
Definition: pathcch.h:302

Referenced by move_dir_to_dir(), and PathIsDirectoryEmptyA().

◆ PathIsDirectoryW()

BOOL WINAPI PathIsDirectoryW ( LPCWSTR  lpszPath)

Definition at line 669 of file path.c.

670{
671 DWORD dwAttr;
672
673 TRACE("(%s)\n", debugstr_w(lpszPath));
674
675 if (!lpszPath || PathIsUNCServerW(lpszPath))
676 return FALSE;
677
678 if (PathIsUNCServerShareW(lpszPath))
679 {
680#ifdef __REACTOS__
681 LPWSTR lpSystem = NULL;
682 BYTE buffer[1024] = {0};
683 DWORD cbBuffer = sizeof(buffer);
685 DWORD dwError;
686
687 pNetRes->dwScope = RESOURCE_GLOBALNET;
688 pNetRes->dwType = RESOURCETYPE_ANY;
689 pNetRes->lpRemoteName = (LPWSTR)lpszPath;
690
691 dwError = WNetGetResourceInformationW(pNetRes, pNetRes, &cbBuffer, &lpSystem);
692 if (dwError == NO_ERROR && pNetRes->dwDisplayType != RESOURCEDISPLAYTYPE_GENERIC)
693 {
694 return (pNetRes->dwDisplayType == RESOURCEDISPLAYTYPE_SHARE) &&
695 (pNetRes->dwType == RESOURCETYPE_ANY || pNetRes->dwType == RESOURCETYPE_DISK);
696 }
697#else
698 FIXME("UNC Server Share not yet supported - FAILING\n");
699 return FALSE;
700#endif
701 }
702
703 if ((dwAttr = GetFileAttributesW(lpszPath)) == INVALID_FILE_ATTRIBUTES)
704 return FALSE;
705 return dwAttr & FILE_ATTRIBUTE_DIRECTORY;
706}
DWORD dwType
Definition: winnetwk.h:178
DWORD dwDisplayType
Definition: winnetwk.h:179
DWORD dwScope
Definition: winnetwk.h:177
LPWSTR lpRemoteName
Definition: winnetwk.h:182
struct _NETRESOURCEW * LPNETRESOURCEW
DWORD WINAPI WNetGetResourceInformationW(LPNETRESOURCEW lpNetResource, LPVOID lpBuffer, LPDWORD cbBuffer, LPWSTR *lplpSystem)
Definition: wnet.c:1937

Referenced by CDirectoryList::AddPathsFromDirectory(), BrFolder_OnOK(), copy_file(), create_target_directory(), CreateDirectoryWatcherFromRegEntry(), DetermineDialogBoxType(), CAppScrnshotPreview::DisplayImage(), DoAddFilesFromItem(), DoBuildFilesAndDirs(), DoTestEntry(), CDeskLinkDropHandler::Drop(), CAddressEditBox::ExecuteCommandLine(), FILEDLG95_InitControls(), CFSFolder::GetCustomViewInfo(), getIconLocationForFolder(), CFileDefExt::Initialize(), InstallFontFiles(), PathIsDirectoryEmptyW(), ATL::CPathT< StringType >::PathIsDirectoryX(), CDirectoryWatcher::ProcessNotification(), SHAddToRecentDocs(), SHELL_execute(), SHExplorerParseCmdLine(), ShowCreateShortcutWizard(), WindowProc(), and wWinMain().

◆ PathIsNetworkPathA()

BOOL WINAPI PathIsNetworkPathA ( LPCSTR  lpszPath)

Definition at line 1308 of file path.c.

1309{
1310 int dwDriveNum;
1311
1312 TRACE("(%s)\n",debugstr_a(lpszPath));
1313
1314 if (!lpszPath)
1315 return FALSE;
1316 if (*lpszPath == '\\' && lpszPath[1] == '\\')
1317 return TRUE;
1318 dwDriveNum = PathGetDriveNumberA(lpszPath);
1319 if (dwDriveNum == -1)
1320 return FALSE;
1321#ifdef __REACTOS__
1322 return IsNetDrive(dwDriveNum);
1323#else
1324 GET_FUNC(pIsNetDrive, shell32, (LPCSTR)66, FALSE); /* ord 66 = shell32.IsNetDrive */
1325 return pIsNetDrive(dwDriveNum);
1326#endif
1327}
@ shell32
Definition: LocaleTests.cpp:20
int WINAPI PathGetDriveNumberA(const char *path)
Definition: path.c:1774
#define GET_FUNC(func, module, name, fail)
Definition: path.c:52
static fnpIsNetDrive pIsNetDrive
Definition: path.c:66
EXTERN_C int WINAPI IsNetDrive(int drive)
Definition: shlfileop.cpp:2342

◆ PathIsNetworkPathW()

BOOL WINAPI PathIsNetworkPathW ( LPCWSTR  lpszPath)

Definition at line 1334 of file path.c.

1335{
1336 int dwDriveNum;
1337
1338 TRACE("(%s)\n", debugstr_w(lpszPath));
1339
1340 if (!lpszPath)
1341 return FALSE;
1342 if (*lpszPath == '\\' && lpszPath[1] == '\\')
1343 return TRUE;
1344 dwDriveNum = PathGetDriveNumberW(lpszPath);
1345 if (dwDriveNum == -1)
1346 return FALSE;
1347#ifdef __REACTOS__
1348 return IsNetDrive(dwDriveNum);
1349#else
1350 GET_FUNC(pIsNetDrive, shell32, (LPCSTR)66, FALSE); /* ord 66 = shell32.IsNetDrive */
1351 return pIsNetDrive(dwDriveNum);
1352#endif
1353}
int WINAPI PathGetDriveNumberW(const WCHAR *path)
Definition: path.c:1786

◆ PathIsSystemFolderA()

BOOL WINAPI PathIsSystemFolderA ( LPCSTR  lpszPath,
DWORD  dwAttrib 
)

Definition at line 834 of file path.c.

835{
836 TRACE("(%s,0x%08lx)\n", debugstr_a(lpszPath), dwAttrib);
837
838 if (lpszPath && *lpszPath)
839 dwAttrib = GetFileAttributesA(lpszPath);
840
841 if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY) ||
843 return FALSE;
844 return TRUE;
845}
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704

◆ PathIsSystemFolderW()

BOOL WINAPI PathIsSystemFolderW ( LPCWSTR  lpszPath,
DWORD  dwAttrib 
)

Definition at line 852 of file path.c.

853{
854 TRACE("(%s,0x%08lx)\n", debugstr_w(lpszPath), dwAttrib);
855
856 if (lpszPath && *lpszPath)
857 dwAttrib = GetFileAttributesW(lpszPath);
858
859 if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY) ||
861 return FALSE;
862 return TRUE;
863}

Referenced by CViewStatePropertyBag::_IsSystemFolder().

◆ PathMakePrettyA()

BOOL WINAPI PathMakePrettyA ( LPSTR  lpszPath)

Definition at line 877 of file path.c.

878{
879 LPSTR pszIter = lpszPath;
880
881 TRACE("(%s)\n", debugstr_a(lpszPath));
882
883 if (!pszIter)
884 return FALSE;
885
886 if (*pszIter)
887 {
888 do
889 {
890 if (islower(*pszIter) || IsDBCSLeadByte(*pszIter))
891 return FALSE; /* Not DOS path */
892 pszIter++;
893 } while (*pszIter);
894 pszIter = lpszPath + 1;
895 while (*pszIter)
896 {
897 *pszIter = tolower(*pszIter);
898 pszIter++;
899 }
900 }
901 return TRUE;
902}
#define islower(c)
Definition: acclib.h:72
BOOL WINAPI IsDBCSLeadByte(BYTE testchar)
Definition: locale.c:2126
int CDECL tolower(int c)
Definition: ctype.c:572

Referenced by ATL::CPathT< StringType >::PathMakePrettyX(), and test_PathMakePretty().

◆ PathMakePrettyW()

BOOL WINAPI PathMakePrettyW ( LPWSTR  lpszPath)

Definition at line 909 of file path.c.

910{
911 LPWSTR pszIter = lpszPath;
912
913 TRACE("(%s)\n", debugstr_w(lpszPath));
914
915 if (!pszIter)
916 return FALSE;
917
918 if (*pszIter)
919 {
920 do
921 {
922 if (iswlower(*pszIter))
923 return FALSE; /* Not DOS path */
924 pszIter++;
925 } while (*pszIter);
926 pszIter = lpszPath + 1;
927 while (*pszIter)
928 {
929 *pszIter = towlower(*pszIter);
930 pszIter++;
931 }
932 }
933 return TRUE;
934}
#define iswlower(_c)
Definition: ctype.h:666
#define towlower(c)
Definition: wctype.h:97

Referenced by ATL::CPathT< StringType >::PathMakePrettyX().

◆ PathMakeSystemFolderA()

BOOL WINAPI PathMakeSystemFolderA ( LPCSTR  lpszPath)

Definition at line 1130 of file path.c.

1131{
1132 BOOL bRet = FALSE;
1133
1134 TRACE("(%s)\n", debugstr_a(lpszPath));
1135
1136 if (lpszPath && *lpszPath)
1137 {
1141 }
1142 return bRet;
1143}
BOOL WINAPI PathMakeSystemFolderW(LPCWSTR lpszPath)
Definition: path.c:1150

◆ PathMakeSystemFolderW()

BOOL WINAPI PathMakeSystemFolderW ( LPCWSTR  lpszPath)

Definition at line 1150 of file path.c.

1151{
1152 DWORD dwDefaultAttr = FILE_ATTRIBUTE_READONLY, dwAttr;
1154
1155 TRACE("(%s)\n", debugstr_w(lpszPath));
1156
1157 if (!lpszPath || !*lpszPath)
1158 return FALSE;
1159
1160 /* If the directory is already a system directory, don't do anything */
1162 if (!wcscmp(buff, lpszPath))
1163 return TRUE;
1164
1166 if (!wcscmp(buff, lpszPath))
1167 return TRUE;
1168
1169 /* "UseSystemForSystemFolders" Tells Win what attributes to use */
1171 dwDefaultAttr = FILE_ATTRIBUTE_SYSTEM;
1172
1173 if ((dwAttr = GetFileAttributesW(lpszPath)) == INVALID_FILE_ATTRIBUTES)
1174 return FALSE;
1175
1176 /* Change file attributes to system attributes */
1178 return SetFileAttributesW(lpszPath, dwAttr | dwDefaultAttr);
1179}
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:778
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2232
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2271
static BOOL SHLWAPI_UseSystemForSystemFolders(void)
Definition: path.c:1100
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703

Referenced by PathMakeSystemFolderA(), and SHCreatePropertyBagOnProfileSection().

◆ PathRemoveArgsA()

void WINAPI PathRemoveArgsA ( LPSTR  lpszPath)

Definition at line 130 of file path.c.

131{
132 TRACE("(%s)\n",debugstr_a(lpszPath));
133
134 if(lpszPath)
135 {
136 LPSTR lpszArgs = PathGetArgsA(lpszPath);
137 if (*lpszArgs)
138 lpszArgs[-1] = '\0';
139 else
140 {
141 LPSTR lpszLastChar = CharPrevA(lpszPath, lpszArgs);
142 if(*lpszLastChar == ' ')
143 *lpszLastChar = '\0';
144 }
145 }
146}
char *WINAPI PathGetArgsA(const char *path)
Definition: path.c:1694
LPSTR WINAPI CharPrevA(const char *start, const char *ptr)
Definition: string.c:1172

Referenced by ATL::CPathT< StringType >::PathRemoveArgsX().

◆ PathRemoveArgsW()

void WINAPI PathRemoveArgsW ( LPWSTR  lpszPath)

Definition at line 153 of file path.c.

154{
155 TRACE("(%s)\n",debugstr_w(lpszPath));
156
157 if(lpszPath)
158 {
159 LPWSTR lpszArgs = PathGetArgsW(lpszPath);
160 if (*lpszArgs || (lpszArgs > lpszPath && lpszArgs[-1] == ' '))
161 lpszArgs[-1] = '\0';
162 }
163}
WCHAR *WINAPI PathGetArgsW(const WCHAR *path)
Definition: path.c:1716

Referenced by RunOnceExEntry::Exec(), CAddressEditBox::ExecuteCommandLine(), CShellLink::OnNotify(), OpensWithExplorer(), ATL::CPathT< StringType >::PathRemoveArgsX(), SHELL_execute(), SHELL_translate_idlist(), ShellExecuteCommand(), and WelcomeDlgProc().

◆ PathSetDlgItemPathA()

VOID WINAPI PathSetDlgItemPathA ( HWND  hDlg,
int  id,
LPCSTR  lpszPath 
)

Definition at line 1246 of file path.c.

1247{
1249
1250 TRACE("(%p,%8x,%s)\n",hDlg, id, debugstr_a(lpszPath));
1251
1252 if (lpszPath)
1254 else
1255 szPath[0] = '\0';
1256 PathSetDlgItemPathW(hDlg, id, szPath);
1257}
VOID WINAPI PathSetDlgItemPathW(HWND hDlg, int id, LPCWSTR lpszPath)
Definition: path.c:1264

◆ PathSetDlgItemPathW()

VOID WINAPI PathSetDlgItemPathW ( HWND  hDlg,
int  id,
LPCWSTR  lpszPath 
)

Definition at line 1264 of file path.c.

1265{
1266 WCHAR path[MAX_PATH + 1];
1267 HWND hwItem;
1268 RECT rect;
1269 HDC hdc;
1270 HGDIOBJ hPrevObj;
1271
1272 TRACE("(%p,%8x,%s)\n",hDlg, id, debugstr_w(lpszPath));
1273
1274 if (!(hwItem = GetDlgItem(hDlg, id)))
1275 return;
1276
1277 if (lpszPath)
1278 lstrcpynW(path, lpszPath, ARRAY_SIZE(path));
1279 else
1280 path[0] = '\0';
1281
1282 GetClientRect(hwItem, &rect);
1283 hdc = GetDC(hDlg);
1284 hPrevObj = SelectObject(hdc, (HGDIOBJ)SendMessageW(hwItem,WM_GETFONT,0,0));
1285
1286 if (hPrevObj)
1287 {
1289 SelectObject(hdc, hPrevObj);
1290 }
1291
1292 ReleaseDC(hDlg, hdc);
1293 SetWindowTextW(hwItem, path);
1294}
#define ARRAY_SIZE(A)
Definition: main.h:20
RECT rect
Definition: combotst.c:67
LONG right
Definition: windef.h:108
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define WM_GETFONT
Definition: winuser.h:1679
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by PathSetDlgItemPathA().

◆ PathUndecorateA()

void WINAPI PathUndecorateA ( char path)

Definition at line 1520 of file path.c.

1521{
1522 char *ext, *skip;
1523
1524 TRACE("(%s)\n", debugstr_a(path));
1525
1526 if (!path) return;
1527
1529 if (ext == path || ext[-1] != ']') return;
1530
1531 skip = ext - 2;
1532 while (skip > path && '0' <= *skip && *skip <= '9')
1533 skip--;
1534
1535 if (skip > path && *skip == '[' && skip[-1] != '\\')
1536 memmove(skip, ext, strlen(ext) + 1);
1537}
#define skip(...)
Definition: atltest.h:64
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

Referenced by test_PathUndecorate().

◆ PathUndecorateW()

void WINAPI PathUndecorateW ( WCHAR path)

Definition at line 1544 of file path.c.

1545{
1546 WCHAR *ext, *skip;
1547
1548 TRACE("(%s)\n", debugstr_w(path));
1549
1550 if (!path) return;
1551
1553 if (ext == path || ext[-1] != ']') return;
1554
1555 skip = ext - 2;
1556 while (skip > path && '0' <= *skip && *skip <= '9')
1557 skip--;
1558
1559 if (skip > path && *skip == '[' && skip[-1] != '\\')
1560 memmove(skip, ext, (wcslen(ext) + 1) * sizeof(WCHAR));
1561}
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988

Referenced by test_PathUndecorate().

◆ PathUnmakeSystemFolderA()

BOOL WINAPI PathUnmakeSystemFolderA ( LPCSTR  lpszPath)

Definition at line 1194 of file path.c.

1195{
1196 DWORD dwAttr;
1197
1198 TRACE("(%s)\n", debugstr_a(lpszPath));
1199
1200 if (!lpszPath || !*lpszPath || (dwAttr = GetFileAttributesA(lpszPath)) == INVALID_FILE_ATTRIBUTES ||
1201 !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
1202 return FALSE;
1203
1205 return SetFileAttributesA(lpszPath, dwAttr);
1206}
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:760

◆ PathUnmakeSystemFolderW()

BOOL WINAPI PathUnmakeSystemFolderW ( LPCWSTR  lpszPath)

Definition at line 1213 of file path.c.

1214{
1215 DWORD dwAttr;
1216
1217 TRACE("(%s)\n", debugstr_w(lpszPath));
1218
1219 if (!lpszPath || !*lpszPath || (dwAttr = GetFileAttributesW(lpszPath)) == INVALID_FILE_ATTRIBUTES ||
1220 !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
1221 return FALSE;
1222
1224 return SetFileAttributesW(lpszPath, dwAttr);
1225}

◆ SHGetWebFolderFilePathA()

HRESULT WINAPI SHGetWebFolderFilePathA ( LPCSTR  lpszFile,
LPSTR  lpszPath,
DWORD  dwPathLen 
)

Definition at line 1577 of file path.c.

1578{
1579 WCHAR szFile[MAX_PATH], szPath[MAX_PATH];
1580 HRESULT hRet;
1581
1582 TRACE("(%s,%p,%ld)\n", lpszFile, lpszPath, dwPathLen);
1583
1584 MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, szFile, MAX_PATH);
1585 szPath[0] = '\0';
1586 hRet = SHGetWebFolderFilePathW(szFile, szPath, dwPathLen);
1587 WideCharToMultiByte(CP_ACP, 0, szPath, -1, lpszPath, dwPathLen, 0, 0);
1588 return hRet;
1589}
HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR, LPWSTR, DWORD)
Definition: path.c:1596

◆ SHGetWebFolderFilePathW()

HRESULT WINAPI SHGetWebFolderFilePathW ( LPCWSTR  lpszFile,
LPWSTR  lpszPath,
DWORD  dwPathLen 
)

Definition at line 1596 of file path.c.

1597{
1598 static const WCHAR szWeb[] = {'\\','W','e','b','\\','\0'};
1599 static const WCHAR szWebMui[] = {'m','u','i','\\','%','0','4','x','\\','\0'};
1600 DWORD dwLen, dwFileLen;
1601 LANGID lidSystem, lidUser;
1602
1603 TRACE("(%s,%p,%ld)\n", debugstr_w(lpszFile), lpszPath, dwPathLen);
1604
1605 /* Get base directory for web content */
1606 dwLen = GetSystemWindowsDirectoryW(lpszPath, dwPathLen);
1607 if (dwLen > 0 && lpszPath[dwLen-1] == '\\')
1608 dwLen--;
1609
1610 dwFileLen = lstrlenW(lpszFile);
1611
1612 if (dwLen + dwFileLen + ARRAY_SIZE(szWeb) >= dwPathLen)
1613 return E_FAIL; /* lpszPath too short */
1614
1615 lstrcpyW(lpszPath+dwLen, szWeb);
1616 dwLen += ARRAY_SIZE(szWeb);
1617 dwPathLen = dwPathLen - dwLen; /* Remaining space */
1618
1619 lidSystem = GetSystemDefaultUILanguage();
1620 lidUser = GetUserDefaultUILanguage();
1621
1622 if (lidSystem != lidUser)
1623 {
1624 if (dwFileLen + ARRAY_SIZE(szWebMui) < dwPathLen)
1625 {
1626 /* Use localised content in the users UI language if present */
1627 wsprintfW(lpszPath + dwLen, szWebMui, lidUser);
1628 lstrcpyW(lpszPath + dwLen + ARRAY_SIZE(szWebMui), lpszFile);
1629 if (PathFileExistsW(lpszPath))
1630 return S_OK;
1631 }
1632 }
1633
1634 /* Fall back to OS default installed content */
1635 lstrcpyW(lpszPath + dwLen, lpszFile);
1636 if (PathFileExistsW(lpszPath))
1637 return S_OK;
1638 return E_FAIL;
1639}
#define E_FAIL
Definition: ddrawi.h:102
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2316
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: locale.c:1380
LANGID WINAPI GetSystemDefaultUILanguage(void)
Definition: locale.c:1400
#define S_OK
Definition: intsafe.h:52
USHORT LANGID
Definition: mui.h:9
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

Referenced by SHGetWebFolderFilePathA().

◆ SHLWAPI_PathFindInOtherDirs()

static BOOL SHLWAPI_PathFindInOtherDirs ( LPWSTR  lpszFile,
DWORD  dwWhich 
)
static

Definition at line 270 of file path.c.

271{
272 static const WCHAR szSystem[] = { 'S','y','s','t','e','m','\0'};
273 static const WCHAR szPath[] = { 'P','A','T','H','\0'};
274 DWORD dwLenPATH;
275 LPCWSTR lpszCurr;
276 WCHAR *lpszPATH;
278
279 TRACE("(%s,%08lx)\n", debugstr_w(lpszFile), dwWhich);
280
281 /* Try system directories */
283 if (!PathAppendW(buff, lpszFile))
284 return FALSE;
285 if (PathFileExistsDefExtW(buff, dwWhich))
286 {
287 lstrcpyW(lpszFile, buff);
288 return TRUE;
289 }
291 if (!PathAppendW(buff, szSystem ) || !PathAppendW(buff, lpszFile))
292 return FALSE;
293 if (PathFileExistsDefExtW(buff, dwWhich))
294 {
295 lstrcpyW(lpszFile, buff);
296 return TRUE;
297 }
299 if (!PathAppendW(buff, lpszFile))
300 return FALSE;
301 if (PathFileExistsDefExtW(buff, dwWhich))
302 {
303 lstrcpyW(lpszFile, buff);
304 return TRUE;
305 }
306 /* Try dirs listed in %PATH% */
308
309 if (!dwLenPATH || !(lpszPATH = malloc((dwLenPATH + 1) * sizeof (WCHAR))))
310 return FALSE;
311
312 GetEnvironmentVariableW(szPath, lpszPATH, dwLenPATH + 1);
313 lpszCurr = lpszPATH;
314 while (lpszCurr)
315 {
316 LPCWSTR lpszEnd = lpszCurr;
317 LPWSTR pBuff = buff;
318
319 while (*lpszEnd == ' ')
320 lpszEnd++;
321 while (*lpszEnd && *lpszEnd != ';')
322 *pBuff++ = *lpszEnd++;
323 *pBuff = '\0';
324
325 if (*lpszEnd)
326 lpszCurr = lpszEnd + 1;
327 else
328 lpszCurr = NULL; /* Last Path, terminate after this */
329
330 if (!PathAppendW(buff, lpszFile))
331 {
332 free(lpszPATH);
333 return FALSE;
334 }
335 if (PathFileExistsDefExtW(buff, dwWhich))
336 {
337 lstrcpyW(lpszFile, buff);
338 free(lpszPATH);
339 return TRUE;
340 }
341 }
342 free(lpszPATH);
343 return FALSE;
344}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define PathAppendW
Definition: pathcch.h:310

Referenced by PathFindOnPathExA(), and PathFindOnPathExW().

◆ SHLWAPI_UseSystemForSystemFolders()

static BOOL SHLWAPI_UseSystemForSystemFolders ( void  )
static

Definition at line 1100 of file path.c.

1101{
1102 static BOOL bCheckedReg = FALSE;
1103 static BOOL bUseSystemForSystemFolders = FALSE;
1104
1105 if (!bCheckedReg)
1106 {
1107 bCheckedReg = TRUE;
1108
1109 /* Key tells Win what file attributes to use on system folders */
1111 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
1112 "UseSystemForSystemFolders", 0, 0, 0))
1113 bUseSystemForSystemFolders = TRUE;
1114 }
1115 return bUseSystemForSystemFolders;
1116}
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by PathMakeSystemFolderW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ pIsNetDrive

fnpIsNetDrive pIsNetDrive
static

Definition at line 66 of file path.c.

Referenced by PathIsNetworkPathA(), and PathIsNetworkPathW().

◆ SHLWAPI_hshell32

HMODULE SHLWAPI_hshell32
static

Definition at line 62 of file path.c.