ReactOS 0.4.17-dev-164-gdf7c1fb
path.c File Reference
#include "config.h"
#include "wine/port.h"
#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.

Classes

struct  envvars_map
 

Macros

#define NO_SHLWAPI_STREAM
 
#define GET_FUNC(func, module, name, fail)
 
#define szWebLen   (sizeof(szWeb)/sizeof(WCHAR))
 
#define szWebMuiLen   ((sizeof(szWebMui)+1)/sizeof(WCHAR))
 
#define PATH_CHAR_CLASS_LETTER   0x00000001
 
#define PATH_CHAR_CLASS_ASTERIX   0x00000002
 
#define PATH_CHAR_CLASS_DOT   0x00000004
 
#define PATH_CHAR_CLASS_BACKSLASH   0x00000008
 
#define PATH_CHAR_CLASS_COLON   0x00000010
 
#define PATH_CHAR_CLASS_SEMICOLON   0x00000020
 
#define PATH_CHAR_CLASS_COMMA   0x00000040
 
#define PATH_CHAR_CLASS_SPACE   0x00000080
 
#define PATH_CHAR_CLASS_OTHER_VALID   0x00000100
 
#define PATH_CHAR_CLASS_DOUBLEQUOTE   0x00000200
 
#define PATH_CHAR_CLASS_INVALID   0x00000000
 
#define PATH_CHAR_CLASS_ANY   0xffffffff
 

Typedefs

typedef BOOL(WINAPIfnpIsNetDrive) (int)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
HRESULT WINAPI SHGetWebFolderFilePathW (LPCWSTR, LPWSTR, DWORD)
 
static WCHARheap_strdupAtoW (LPCSTR str)
 
BOOL WINAPI PathAppendA (LPSTR lpszPath, LPCSTR lpszAppend)
 
BOOL WINAPI PathAppendW (LPWSTR lpszPath, LPCWSTR lpszAppend)
 
LPSTR WINAPI PathCombineA (LPSTR lpszDest, LPCSTR lpszDir, LPCSTR lpszFile)
 
LPWSTR WINAPI PathCombineW (LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
 
LPSTR WINAPI PathAddBackslashA (LPSTR lpszPath)
 
LPWSTR WINAPI PathAddBackslashW (LPWSTR lpszPath)
 
LPSTR WINAPI PathBuildRootA (LPSTR lpszPath, int drive)
 
LPWSTR WINAPI PathBuildRootW (LPWSTR lpszPath, int drive)
 
LPSTR WINAPI PathFindFileNameA (LPCSTR lpszPath)
 
LPWSTR WINAPI PathFindFileNameW (LPCWSTR lpszPath)
 
LPSTR WINAPI PathFindExtensionA (LPCSTR lpszPath)
 
LPWSTR WINAPI PathFindExtensionW (LPCWSTR lpszPath)
 
LPSTR WINAPI PathGetArgsA (LPCSTR lpszPath)
 
LPWSTR WINAPI PathGetArgsW (LPCWSTR lpszPath)
 
int WINAPI PathGetDriveNumberA (LPCSTR lpszPath)
 
int WINAPI PathGetDriveNumberW (const WCHAR *path)
 
BOOL WINAPI PathRemoveFileSpecA (LPSTR lpszPath)
 
BOOL WINAPI PathRemoveFileSpecW (LPWSTR lpszPath)
 
void WINAPI PathStripPathA (LPSTR lpszPath)
 
void WINAPI PathStripPathW (LPWSTR lpszPath)
 
BOOL WINAPI PathStripToRootA (LPSTR lpszPath)
 
BOOL WINAPI PathStripToRootW (LPWSTR lpszPath)
 
void WINAPI PathRemoveArgsA (LPSTR lpszPath)
 
void WINAPI PathRemoveArgsW (LPWSTR lpszPath)
 
void WINAPI PathRemoveExtensionA (LPSTR lpszPath)
 
void WINAPI PathRemoveExtensionW (LPWSTR lpszPath)
 
LPSTR WINAPI PathRemoveBackslashA (LPSTR lpszPath)
 
LPWSTR WINAPI PathRemoveBackslashW (LPWSTR lpszPath)
 
void WINAPI PathRemoveBlanksA (LPSTR pszPath)
 
void WINAPI PathRemoveBlanksW (LPWSTR pszPath)
 
VOID WINAPI PathQuoteSpacesA (LPSTR lpszPath)
 
VOID WINAPI PathQuoteSpacesW (LPWSTR lpszPath)
 
VOID WINAPI PathUnquoteSpacesA (LPSTR lpszPath)
 
VOID WINAPI PathUnquoteSpacesW (LPWSTR lpszPath)
 
int WINAPI PathParseIconLocationA (LPSTR lpszPath)
 
int WINAPI PathParseIconLocationW (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 PathIsRelativeA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsRelativeW (LPCWSTR lpszPath)
 
BOOL WINAPI PathIsRootA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsRootW (LPCWSTR lpszPath)
 
BOOL WINAPI PathIsDirectoryA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsDirectoryW (LPCWSTR lpszPath)
 
BOOL WINAPI PathFileExistsA (LPCSTR lpszPath)
 
BOOL WINAPI PathFileExistsW (LPCWSTR lpszPath)
 
BOOL WINAPI PathFileExistsAndAttributesA (LPCSTR lpszPath, DWORD *dwAttr)
 
BOOL WINAPI PathFileExistsAndAttributesW (LPCWSTR lpszPath, DWORD *dwAttr)
 
static BOOL PathMatchSingleMaskA (LPCSTR name, LPCSTR mask)
 
static BOOL PathMatchSingleMaskW (LPCWSTR name, LPCWSTR mask)
 
BOOL WINAPI PathMatchSpecA (LPCSTR lpszPath, LPCSTR lpszMask)
 
BOOL WINAPI PathMatchSpecW (LPCWSTR lpszPath, LPCWSTR lpszMask)
 
BOOL WINAPI PathIsSameRootA (LPCSTR lpszPath1, LPCSTR lpszPath2)
 
BOOL WINAPI PathIsSameRootW (LPCWSTR lpszPath1, LPCWSTR lpszPath2)
 
BOOL WINAPI PathIsContentTypeA (LPCSTR lpszPath, LPCSTR lpszContentType)
 
BOOL WINAPI PathIsContentTypeW (LPCWSTR lpszPath, LPCWSTR lpszContentType)
 
BOOL WINAPI PathIsFileSpecA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsFileSpecW (LPCWSTR lpszPath)
 
BOOL WINAPI PathIsPrefixA (LPCSTR lpszPrefix, LPCSTR lpszPath)
 
BOOL WINAPI PathIsPrefixW (LPCWSTR lpszPrefix, LPCWSTR lpszPath)
 
BOOL WINAPI PathIsSystemFolderA (LPCSTR lpszPath, DWORD dwAttrib)
 
BOOL WINAPI PathIsSystemFolderW (LPCWSTR lpszPath, DWORD dwAttrib)
 
BOOL WINAPI PathIsUNCA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsUNCW (LPCWSTR lpszPath)
 
BOOL WINAPI PathIsUNCServerA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsUNCServerW (LPCWSTR lpszPath)
 
BOOL WINAPI PathIsUNCServerShareA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsUNCServerShareW (LPCWSTR lpszPath)
 
BOOL WINAPI PathCanonicalizeA (LPSTR lpszBuf, LPCSTR lpszPath)
 
BOOL WINAPI PathCanonicalizeW (LPWSTR lpszBuf, LPCWSTR lpszPath)
 
LPSTR WINAPI PathFindNextComponentA (LPCSTR lpszPath)
 
LPWSTR WINAPI PathFindNextComponentW (LPCWSTR lpszPath)
 
BOOL WINAPI PathAddExtensionA (LPSTR lpszPath, LPCSTR lpszExtension)
 
BOOL WINAPI PathAddExtensionW (LPWSTR lpszPath, LPCWSTR lpszExtension)
 
BOOL WINAPI PathMakePrettyA (LPSTR lpszPath)
 
BOOL WINAPI PathMakePrettyW (LPWSTR lpszPath)
 
int WINAPI PathCommonPrefixA (LPCSTR lpszFile1, LPCSTR lpszFile2, LPSTR achPath)
 
int WINAPI PathCommonPrefixW (LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPath)
 
BOOL WINAPI PathCompactPathA (HDC hDC, LPSTR lpszPath, UINT dx)
 
BOOL WINAPI PathCompactPathW (HDC hDC, LPWSTR lpszPath, UINT dx)
 
UINT WINAPI PathGetCharTypeA (UCHAR ch)
 
UINT WINAPI PathGetCharTypeW (WCHAR ch)
 
static BOOL SHLWAPI_UseSystemForSystemFolders (void)
 
BOOL WINAPI PathMakeSystemFolderA (LPCSTR lpszPath)
 
BOOL WINAPI PathMakeSystemFolderW (LPCWSTR lpszPath)
 
BOOL WINAPI PathRenameExtensionA (LPSTR lpszPath, LPCSTR lpszExt)
 
BOOL WINAPI PathRenameExtensionW (LPWSTR lpszPath, LPCWSTR lpszExt)
 
BOOL WINAPI PathSearchAndQualifyA (LPCSTR lpszPath, LPSTR lpszBuf, UINT cchBuf)
 
BOOL WINAPI PathSearchAndQualifyW (LPCWSTR lpszPath, LPWSTR lpszBuf, UINT cchBuf)
 
LPSTR WINAPI PathSkipRootA (LPCSTR lpszPath)
 
LPWSTR WINAPI PathSkipRootW (LPCWSTR lpszPath)
 
HRESULT WINAPI PathCreateFromUrlA (LPCSTR pszUrl, LPSTR pszPath, LPDWORD pcchPath, DWORD dwReserved)
 
HRESULT WINAPI PathCreateFromUrlW (LPCWSTR pszUrl, LPWSTR pszPath, LPDWORD pcchPath, DWORD dwReserved)
 
HRESULT WINAPI PathCreateFromUrlAlloc (LPCWSTR pszUrl, LPWSTR *pszPath, DWORD dwReserved)
 
BOOL WINAPI PathRelativePathToA (LPSTR lpszPath, LPCSTR lpszFrom, DWORD dwAttrFrom, LPCSTR lpszTo, DWORD dwAttrTo)
 
BOOL WINAPI PathRelativePathToW (LPWSTR lpszPath, LPCWSTR lpszFrom, DWORD dwAttrFrom, LPCWSTR lpszTo, DWORD dwAttrTo)
 
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 PathIsLFNFileSpecA (LPCSTR lpszPath)
 
BOOL WINAPI PathIsLFNFileSpecW (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 (LPSTR pszPath)
 
void WINAPI PathUndecorateW (LPWSTR pszPath)
 
BOOL WINAPI PathUnExpandEnvStringsA (LPCSTR path, LPSTR buffer, UINT buf_len)
 
static void init_envvars_map (struct envvars_map *map)
 
BOOL WINAPI PathUnExpandEnvStringsW (LPCWSTR path, LPWSTR buffer, UINT buf_len)
 
HRESULT WINAPI SHGetWebFolderFilePathA (LPCSTR lpszFile, LPSTR lpszPath, DWORD dwPathLen)
 
BOOL WINAPI PathIsValidCharA (char c, DWORD class)
 
BOOL WINAPI PathIsValidCharW (WCHAR c, DWORD class)
 

Variables

static HMODULE SHLWAPI_hshell32
 
static fnpIsNetDrive pIsNetDrive
 
static const WCHAR allusersprofileW [] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%',0}
 
static const WCHAR appdataW [] = {'%','A','P','P','D','A','T','A','%',0}
 
static const WCHAR programfilesW [] = {'%','P','r','o','g','r','a','m','F','i','l','e','s','%',0}
 
static const WCHAR systemrootW [] = {'%','S','y','s','t','e','m','R','o','o','t','%',0}
 
static const WCHAR systemdriveW [] = {'%','S','y','s','t','e','m','D','r','i','v','e','%',0}
 
static const WCHAR userprofileW [] = {'%','U','S','E','R','P','R','O','F','I','L','E','%',0}
 
static const DWORD SHELL_charclass []
 

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 55 of file path.c.

◆ NO_SHLWAPI_STREAM

#define NO_SHLWAPI_STREAM

Definition at line 36 of file path.c.

◆ PATH_CHAR_CLASS_ANY

#define PATH_CHAR_CLASS_ANY   0xffffffff

Definition at line 4361 of file path.c.

◆ PATH_CHAR_CLASS_ASTERIX

#define PATH_CHAR_CLASS_ASTERIX   0x00000002

Definition at line 4350 of file path.c.

◆ PATH_CHAR_CLASS_BACKSLASH

#define PATH_CHAR_CLASS_BACKSLASH   0x00000008

Definition at line 4352 of file path.c.

◆ PATH_CHAR_CLASS_COLON

#define PATH_CHAR_CLASS_COLON   0x00000010

Definition at line 4353 of file path.c.

◆ PATH_CHAR_CLASS_COMMA

#define PATH_CHAR_CLASS_COMMA   0x00000040

Definition at line 4355 of file path.c.

◆ PATH_CHAR_CLASS_DOT

#define PATH_CHAR_CLASS_DOT   0x00000004

Definition at line 4351 of file path.c.

◆ PATH_CHAR_CLASS_DOUBLEQUOTE

#define PATH_CHAR_CLASS_DOUBLEQUOTE   0x00000200

Definition at line 4358 of file path.c.

◆ PATH_CHAR_CLASS_INVALID

#define PATH_CHAR_CLASS_INVALID   0x00000000

Definition at line 4360 of file path.c.

◆ PATH_CHAR_CLASS_LETTER

#define PATH_CHAR_CLASS_LETTER   0x00000001

Definition at line 4349 of file path.c.

◆ PATH_CHAR_CLASS_OTHER_VALID

#define PATH_CHAR_CLASS_OTHER_VALID   0x00000100

Definition at line 4357 of file path.c.

◆ PATH_CHAR_CLASS_SEMICOLON

#define PATH_CHAR_CLASS_SEMICOLON   0x00000020

Definition at line 4354 of file path.c.

◆ PATH_CHAR_CLASS_SPACE

#define PATH_CHAR_CLASS_SPACE   0x00000080

Definition at line 4356 of file path.c.

◆ szWebLen

#define szWebLen   (sizeof(szWeb)/sizeof(WCHAR))

◆ szWebMuiLen

#define szWebMuiLen   ((sizeof(szWebMui)+1)/sizeof(WCHAR))

Typedef Documentation

◆ fnpIsNetDrive

typedef BOOL(WINAPI * fnpIsNetDrive) (int)

Definition at line 68 of file path.c.

Function Documentation

◆ heap_strdupAtoW()

static WCHAR * heap_strdupAtoW ( LPCSTR  str)
inlinestatic

Definition at line 76 of file path.c.

77{
78 WCHAR *ret = NULL;
79
80 if (str)
81 {
83 ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
84 if (ret)
86 }
87
88 return ret;
89}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define MultiByteToWideChar
Definition: compat.h:110
return ret
Definition: mutex.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
short WCHAR
Definition: pedump.c:58
const WCHAR * str

◆ init_envvars_map()

static void init_envvars_map ( struct envvars_map map)
static

Definition at line 4206 of file path.c.

4207{
4208 while (map->var)
4209 {
4210 map->len = ExpandEnvironmentStringsW(map->var, map->path, sizeof(map->path)/sizeof(WCHAR));
4211 /* exclude null from length */
4212 if (map->len) map->len--;
4213 map++;
4214 }
4215}
Definition: _map.h:48
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:520

◆ PathAddBackslashA()

LPSTR WINAPI PathAddBackslashA ( LPSTR  lpszPath)

Definition at line 266 of file path.c.

267{
268 size_t iLen;
269 LPSTR prev = lpszPath;
270
271 TRACE("(%s)\n",debugstr_a(lpszPath));
272
273 if (!lpszPath || (iLen = strlen(lpszPath)) >= MAX_PATH)
274 return NULL;
275
276 if (iLen)
277 {
278 do {
279 lpszPath = CharNextA(prev);
280 if (*lpszPath)
281 prev = lpszPath;
282 } while (*lpszPath);
283 if (*prev != '\\')
284 {
285 *lpszPath++ = '\\';
286 *lpszPath = '\0';
287 }
288 }
289 return lpszPath;
290}
#define MAX_PATH
Definition: compat.h:34
LPSTR WINAPI CharNextA(const char *ptr)
Definition: string.c:1107
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
#define debugstr_a
Definition: kernel32.h:31
#define TRACE(s)
Definition: solgame.cpp:4
char * LPSTR
Definition: typedefs.h:51

◆ PathAddBackslashW()

LPWSTR WINAPI PathAddBackslashW ( LPWSTR  lpszPath)

Definition at line 297 of file path.c.

298{
299 size_t iLen;
300
301 TRACE("(%s)\n",debugstr_w(lpszPath));
302
303 if (!lpszPath || (iLen = strlenW(lpszPath)) >= MAX_PATH)
304 return NULL;
305
306 if (iLen)
307 {
308 lpszPath += iLen;
309 if (lpszPath[-1] != '\\')
310 {
311 *lpszPath++ = '\\';
312 *lpszPath = '\0';
313 }
314 }
315 return lpszPath;
316}
#define debugstr_w
Definition: kernel32.h:32
#define strlenW(s)
Definition: unicode.h:28

◆ PathAddExtensionA()

BOOL WINAPI PathAddExtensionA ( LPSTR  lpszPath,
LPCSTR  lpszExtension 
)

Definition at line 2662 of file path.c.

2663{
2664 size_t dwLen;
2665
2666 TRACE("(%s,%s)\n", debugstr_a(lpszPath), debugstr_a(lpszExtension));
2667
2668 if (!lpszPath || !lpszExtension || *(PathFindExtensionA(lpszPath)))
2669 return FALSE;
2670
2671 dwLen = strlen(lpszPath);
2672
2673 if (dwLen + strlen(lpszExtension) >= MAX_PATH)
2674 return FALSE;
2675
2676 strcpy(lpszPath + dwLen, lpszExtension);
2677 return TRUE;
2678}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LPSTR WINAPI PathFindExtensionA(const char *path)
Definition: path.c:1253
strcpy
Definition: string.h:131

◆ PathAddExtensionW()

BOOL WINAPI PathAddExtensionW ( LPWSTR  lpszPath,
LPCWSTR  lpszExtension 
)

Definition at line 2685 of file path.c.

2686{
2687 size_t dwLen;
2688
2689 TRACE("(%s,%s)\n", debugstr_w(lpszPath), debugstr_w(lpszExtension));
2690
2691 if (!lpszPath || !lpszExtension || *(PathFindExtensionW(lpszPath)))
2692 return FALSE;
2693
2694 dwLen = strlenW(lpszPath);
2695
2696 if (dwLen + strlenW(lpszExtension) >= MAX_PATH)
2697 return FALSE;
2698
2699 strcpyW(lpszPath + dwLen, lpszExtension);
2700 return TRUE;
2701}
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1274
#define strcpyW(d, s)
Definition: unicode.h:29

◆ PathAppendA()

BOOL WINAPI PathAppendA ( LPSTR  lpszPath,
LPCSTR  lpszAppend 
)

Definition at line 109 of file path.c.

110{
111 TRACE("(%s,%s)\n",debugstr_a(lpszPath), debugstr_a(lpszAppend));
112
113 if (lpszPath && lpszAppend)
114 {
115 if (!PathIsUNCA(lpszAppend))
116 while (*lpszAppend == '\\')
117 lpszAppend++;
118 if (PathCombineA(lpszPath, lpszPath, lpszAppend))
119 return TRUE;
120 }
121 return FALSE;
122}
BOOL WINAPI PathIsUNCA(const char *path)
Definition: path.c:1006
#define PathCombineA
Definition: pathcch.h:317

◆ PathAppendW()

BOOL WINAPI PathAppendW ( LPWSTR  lpszPath,
LPCWSTR  lpszAppend 
)

Definition at line 129 of file path.c.

130{
131 TRACE("(%s,%s)\n",debugstr_w(lpszPath), debugstr_w(lpszAppend));
132
133 if (lpszPath && lpszAppend)
134 {
135 if (!PathIsUNCW(lpszAppend))
136 while (*lpszAppend == '\\')
137 lpszAppend++;
138 if (PathCombineW(lpszPath, lpszPath, lpszAppend))
139 return TRUE;
140 }
141 return FALSE;
142}
BOOL WINAPI PathIsUNCW(const WCHAR *path)
Definition: path.c:1013
#define PathCombineW
Definition: pathcch.h:318

◆ PathBuildRootA()

LPSTR WINAPI PathBuildRootA ( LPSTR  lpszPath,
int  drive 
)

Definition at line 332 of file path.c.

333{
334 TRACE("(%p,%d)\n", lpszPath, drive);
335
336 if (lpszPath && drive >= 0 && drive < 26)
337 {
338 lpszPath[0] = 'A' + drive;
339 lpszPath[1] = ':';
340 lpszPath[2] = '\\';
341 lpszPath[3] = '\0';
342 }
343 return lpszPath;
344}

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

◆ PathBuildRootW()

LPWSTR WINAPI PathBuildRootW ( LPWSTR  lpszPath,
int  drive 
)

Definition at line 351 of file path.c.

352{
353 TRACE("(%p,%d)\n", lpszPath, drive);
354
355 if (lpszPath && drive >= 0 && drive < 26)
356 {
357 lpszPath[0] = 'A' + drive;
358 lpszPath[1] = ':';
359 lpszPath[2] = '\\';
360 lpszPath[3] = '\0';
361 }
362 return lpszPath;
363}

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

◆ PathCanonicalizeA()

BOOL WINAPI PathCanonicalizeA ( LPSTR  lpszBuf,
LPCSTR  lpszPath 
)

Definition at line 2460 of file path.c.

2461{
2462 BOOL bRet = FALSE;
2463
2464 TRACE("(%p,%s)\n", lpszBuf, debugstr_a(lpszPath));
2465
2466 if (lpszBuf)
2467 *lpszBuf = '\0';
2468
2469 if (!lpszBuf || !lpszPath)
2471 else
2472 {
2474 WCHAR szBuff[MAX_PATH];
2475 int ret = MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
2476
2477 if (!ret) {
2478 WARN("Failed to convert string to widechar (too long?), LE %d.\n", GetLastError());
2479 return FALSE;
2480 }
2481 bRet = PathCanonicalizeW(szBuff, szPath);
2482 WideCharToMultiByte(CP_ACP,0,szBuff,-1,lpszBuf,MAX_PATH,0,0);
2483 }
2484 return bRet;
2485}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define WideCharToMultiByte
Definition: compat.h:111
unsigned int BOOL
Definition: ntddk_ex.h:94
LPCWSTR szPath
Definition: env.c:37
#define PathCanonicalizeW
Definition: pathcch.h:314
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ PathCanonicalizeW()

BOOL WINAPI PathCanonicalizeW ( LPWSTR  lpszBuf,
LPCWSTR  lpszPath 
)

Definition at line 2493 of file path.c.

2494{
2495 LPWSTR lpszDst = lpszBuf;
2496 LPCWSTR lpszSrc = lpszPath;
2497
2498 TRACE("(%p,%s)\n", lpszBuf, debugstr_w(lpszPath));
2499
2500 if (lpszBuf)
2501 *lpszDst = '\0';
2502
2503 if (!lpszBuf || !lpszPath)
2504 {
2506 return FALSE;
2507 }
2508
2509 if (!*lpszPath)
2510 {
2511 *lpszBuf++ = '\\';
2512 *lpszBuf = '\0';
2513 return TRUE;
2514 }
2515
2516 /* Copy path root */
2517 if (*lpszSrc == '\\')
2518 {
2519 *lpszDst++ = *lpszSrc++;
2520 }
2521 else if (*lpszSrc && lpszSrc[1] == ':')
2522 {
2523 /* X:\ */
2524 *lpszDst++ = *lpszSrc++;
2525 *lpszDst++ = *lpszSrc++;
2526 if (*lpszSrc == '\\')
2527 *lpszDst++ = *lpszSrc++;
2528 }
2529
2530 /* Canonicalize the rest of the path */
2531 while (*lpszSrc)
2532 {
2533 if (*lpszSrc == '.')
2534 {
2535 if (lpszSrc[1] == '\\' && (lpszSrc == lpszPath || lpszSrc[-1] == '\\' || lpszSrc[-1] == ':'))
2536 {
2537 lpszSrc += 2; /* Skip .\ */
2538 }
2539 else if (lpszSrc[1] == '.' && (lpszDst == lpszBuf || lpszDst[-1] == '\\'))
2540 {
2541 /* \.. backs up a directory, over the root if it has no \ following X:.
2542 * .. is ignored if it would remove a UNC server name or initial \\
2543 */
2544 if (lpszDst != lpszBuf)
2545 {
2546 *lpszDst = '\0'; /* Allow PathIsUNCServerShareA test on lpszBuf */
2547 if (lpszDst > lpszBuf+1 && lpszDst[-1] == '\\' &&
2548 (lpszDst[-2] != '\\' || lpszDst > lpszBuf+2))
2549 {
2550 if (lpszDst[-2] == ':' && (lpszDst > lpszBuf+3 || lpszDst[-3] == ':'))
2551 {
2552 lpszDst -= 2;
2553 while (lpszDst > lpszBuf && *lpszDst != '\\')
2554 lpszDst--;
2555 if (*lpszDst == '\\')
2556 lpszDst++; /* Reset to last '\' */
2557 else
2558 lpszDst = lpszBuf; /* Start path again from new root */
2559 }
2560 else if (lpszDst[-2] != ':' && !PathIsUNCServerShareW(lpszBuf))
2561 lpszDst -= 2;
2562 }
2563 while (lpszDst > lpszBuf && *lpszDst != '\\')
2564 lpszDst--;
2565 if (lpszDst == lpszBuf)
2566 {
2567 *lpszDst++ = '\\';
2568 lpszSrc++;
2569 }
2570 }
2571 lpszSrc += 2; /* Skip .. in src path */
2572 }
2573 else
2574 *lpszDst++ = *lpszSrc++;
2575 }
2576 else
2577 *lpszDst++ = *lpszSrc++;
2578 }
2579 /* Append \ to naked drive specs */
2580 if (lpszDst - lpszBuf == 2 && lpszDst[-1] == ':')
2581 *lpszDst++ = '\\';
2582 *lpszDst++ = '\0';
2583 return TRUE;
2584}
BOOL WINAPI PathIsUNCServerShareW(const WCHAR *path)
Definition: path.c:1064
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56

◆ PathCombineA()

LPSTR WINAPI PathCombineA ( LPSTR  lpszDest,
LPCSTR  lpszDir,
LPCSTR  lpszFile 
)

Definition at line 162 of file path.c.

163{
164 WCHAR szDest[MAX_PATH];
165 WCHAR szDir[MAX_PATH];
166 WCHAR szFile[MAX_PATH];
167 TRACE("(%p,%s,%s)\n", lpszDest, debugstr_a(lpszDir), debugstr_a(lpszFile));
168
169 /* Invalid parameters */
170 if (!lpszDest)
171 return NULL;
172 if (!lpszDir && !lpszFile)
173 goto fail;
174
175 if (lpszDir)
176 if (!MultiByteToWideChar(CP_ACP,0,lpszDir,-1,szDir,MAX_PATH))
177 goto fail;
178
179 if (lpszFile)
180 if (!MultiByteToWideChar(CP_ACP,0,lpszFile,-1,szFile,MAX_PATH))
181 goto fail;
182
183 if (PathCombineW(szDest, lpszDir ? szDir : NULL, lpszFile ? szFile : NULL))
184 if (WideCharToMultiByte(CP_ACP,0,szDest,-1,lpszDest,MAX_PATH,0,0))
185 return lpszDest;
186
187fail:
188 lpszDest[0] = 0;
189 return NULL;
190}
WCHAR lpszDest[260]

◆ PathCombineW()

LPWSTR WINAPI PathCombineW ( LPWSTR  lpszDest,
LPCWSTR  lpszDir,
LPCWSTR  lpszFile 
)

Definition at line 197 of file path.c.

198{
199 WCHAR szTemp[MAX_PATH];
200 BOOL bUseBoth = FALSE, bStrip = FALSE;
201
202 TRACE("(%p,%s,%s)\n", lpszDest, debugstr_w(lpszDir), debugstr_w(lpszFile));
203
204 /* Invalid parameters */
205 if (!lpszDest)
206 return NULL;
207 if (!lpszDir && !lpszFile)
208 {
209 lpszDest[0] = 0;
210 return NULL;
211 }
212
213 if ((!lpszFile || !*lpszFile) && lpszDir)
214 {
215 /* Use dir only */
216 lstrcpynW(szTemp, lpszDir, MAX_PATH);
217 }
218 else if (!lpszDir || !*lpszDir || !PathIsRelativeW(lpszFile))
219 {
220 if (!lpszDir || !*lpszDir || *lpszFile != '\\' || PathIsUNCW(lpszFile))
221 {
222 /* Use file only */
223 lstrcpynW(szTemp, lpszFile, MAX_PATH);
224 }
225 else
226 {
227 bUseBoth = TRUE;
228 bStrip = TRUE;
229 }
230 }
231 else
232 bUseBoth = TRUE;
233
234 if (bUseBoth)
235 {
236 lstrcpynW(szTemp, lpszDir, MAX_PATH);
237 if (bStrip)
238 {
239 PathStripToRootW(szTemp);
240 lpszFile++; /* Skip '\' */
241 }
242 if (!PathAddBackslashW(szTemp) || strlenW(szTemp) + strlenW(lpszFile) >= MAX_PATH)
243 {
244 lpszDest[0] = 0;
245 return NULL;
246 }
247 strcatW(szTemp, lpszFile);
248 }
249
251 return lpszDest;
252}
#define lstrcpynW
Definition: compat.h:738
BOOL WINAPI PathIsRelativeW(const WCHAR *path)
Definition: path.c:1030
BOOL WINAPI PathStripToRootW(WCHAR *path)
Definition: path.c:1195
#define PathAddBackslashW
Definition: pathcch.h:302
#define strcatW(d, s)
Definition: unicode.h:30

◆ PathCommonPrefixA()

int WINAPI PathCommonPrefixA ( LPCSTR  lpszFile1,
LPCSTR  lpszFile2,
LPSTR  achPath 
)

Definition at line 2798 of file path.c.

2799{
2800 size_t iLen = 0;
2801 LPCSTR lpszIter1 = lpszFile1;
2802 LPCSTR lpszIter2 = lpszFile2;
2803
2804 TRACE("(%s,%s,%p)\n", debugstr_a(lpszFile1), debugstr_a(lpszFile2), achPath);
2805
2806 if (achPath)
2807 *achPath = '\0';
2808
2809 if (!lpszFile1 || !lpszFile2)
2810 return 0;
2811
2812 /* Handle roots first */
2813 if (PathIsUNCA(lpszFile1))
2814 {
2815 if (!PathIsUNCA(lpszFile2))
2816 return 0;
2817 lpszIter1 += 2;
2818 lpszIter2 += 2;
2819 }
2820 else if (PathIsUNCA(lpszFile2))
2821 return 0; /* Know already lpszFile1 is not UNC */
2822
2823 do
2824 {
2825 /* Update len */
2826 if ((!*lpszIter1 || *lpszIter1 == '\\') &&
2827 (!*lpszIter2 || *lpszIter2 == '\\'))
2828 iLen = lpszIter1 - lpszFile1; /* Common to this point */
2829
2830 if (!*lpszIter1 || (tolower(*lpszIter1) != tolower(*lpszIter2)))
2831 break; /* Strings differ at this point */
2832
2833 lpszIter1++;
2834 lpszIter2++;
2835 } while (1);
2836
2837 if (iLen == 2)
2838 iLen++; /* Feature/Bug compatible with Win32 */
2839
2840 if (iLen && achPath)
2841 {
2842 memcpy(achPath,lpszFile1,iLen);
2843 achPath[iLen] = '\0';
2844 }
2845 return iLen;
2846}
int CDECL tolower(int c)
Definition: ctype.c:572
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
const char * LPCSTR
Definition: typedefs.h:52

◆ PathCommonPrefixW()

int WINAPI PathCommonPrefixW ( LPCWSTR  lpszFile1,
LPCWSTR  lpszFile2,
LPWSTR  achPath 
)

Definition at line 2853 of file path.c.

2854{
2855 size_t iLen = 0;
2856 LPCWSTR lpszIter1 = lpszFile1;
2857 LPCWSTR lpszIter2 = lpszFile2;
2858
2859 TRACE("(%s,%s,%p)\n", debugstr_w(lpszFile1), debugstr_w(lpszFile2), achPath);
2860
2861 if (achPath)
2862 *achPath = '\0';
2863
2864 if (!lpszFile1 || !lpszFile2)
2865 return 0;
2866
2867 /* Handle roots first */
2868 if (PathIsUNCW(lpszFile1))
2869 {
2870 if (!PathIsUNCW(lpszFile2))
2871 return 0;
2872 lpszIter1 += 2;
2873 lpszIter2 += 2;
2874 }
2875 else if (PathIsUNCW(lpszFile2))
2876 return 0; /* Know already lpszFile1 is not UNC */
2877
2878 do
2879 {
2880 /* Update len */
2881 if ((!*lpszIter1 || *lpszIter1 == '\\') &&
2882 (!*lpszIter2 || *lpszIter2 == '\\'))
2883 iLen = lpszIter1 - lpszFile1; /* Common to this point */
2884
2885 if (!*lpszIter1 || (tolowerW(*lpszIter1) != tolowerW(*lpszIter2)))
2886 break; /* Strings differ at this point */
2887
2888 lpszIter1++;
2889 lpszIter2++;
2890 } while (1);
2891
2892 if (iLen == 2)
2893 iLen++; /* Feature/Bug compatible with Win32 */
2894
2895 if (iLen && achPath)
2896 {
2897 memcpy(achPath,lpszFile1,iLen * sizeof(WCHAR));
2898 achPath[iLen] = '\0';
2899 }
2900 return iLen;
2901}
#define tolowerW(n)
Definition: unicode.h:44

◆ PathCompactPathA()

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

Definition at line 2917 of file path.c.

2918{
2919 BOOL bRet = FALSE;
2920
2921 TRACE("(%p,%s,%d)\n", hDC, debugstr_a(lpszPath), dx);
2922
2923 if (lpszPath)
2924 {
2927 bRet = PathCompactPathW(hDC, szPath, dx);
2928 WideCharToMultiByte(CP_ACP,0,szPath,-1,lpszPath,MAX_PATH,0,0);
2929 }
2930 return bRet;
2931}
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx)
Definition: path.c:2938
GLint dx
Definition: linetemp.h:97

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

◆ PathCompactPathExA()

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

Definition at line 1444 of file path.c.

1446{
1447 BOOL bRet = FALSE;
1448
1449 TRACE("(%p,%s,%d,0x%08x)\n", lpszDest, debugstr_a(lpszPath), cchMax, dwFlags);
1450
1451 if (lpszPath && lpszDest)
1452 {
1454 WCHAR szDest[MAX_PATH];
1455
1457 szDest[0] = '\0';
1458 bRet = PathCompactPathExW(szDest, szPath, cchMax, dwFlags);
1460 }
1461 return bRet;
1462}
UINT cchMax
BOOL WINAPI PathCompactPathExW(LPWSTR lpszDest, LPCWSTR lpszPath, UINT cchMax, DWORD dwFlags)
Definition: path.c:1469
_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 1469 of file path.c.

1471{
1472 static const WCHAR szEllipses[] = { '.', '.', '.', '\0' };
1473 LPCWSTR lpszFile;
1474 DWORD dwLen, dwFileLen = 0;
1475
1476 TRACE("(%p,%s,%d,0x%08x)\n", lpszDest, debugstr_w(lpszPath), cchMax, dwFlags);
1477
1478 if (!lpszPath)
1479 return FALSE;
1480
1481 if (!lpszDest)
1482 {
1483 WARN("Invalid lpszDest would crash under Win32!\n");
1484 return FALSE;
1485 }
1486
1487 *lpszDest = '\0';
1488
1489 if (cchMax < 2)
1490 return TRUE;
1491
1492 dwLen = strlenW(lpszPath) + 1;
1493
1494 if (dwLen < cchMax)
1495 {
1496 /* Don't need to compact */
1497 memcpy(lpszDest, lpszPath, dwLen * sizeof(WCHAR));
1498 return TRUE;
1499 }
1500
1501 /* Path must be compacted to fit into lpszDest */
1502 lpszFile = PathFindFileNameW(lpszPath);
1503 dwFileLen = lpszPath + dwLen - lpszFile;
1504
1505 if (dwFileLen == dwLen)
1506 {
1507 /* No root in psth */
1508 if (cchMax <= 4)
1509 {
1510 while (--cchMax > 0) /* No room left for anything but ellipses */
1511 *lpszDest++ = '.';
1512 *lpszDest = '\0';
1513 return TRUE;
1514 }
1515 /* Compact the file name with ellipses at the end */
1516 cchMax -= 4;
1517 memcpy(lpszDest, lpszFile, cchMax * sizeof(WCHAR));
1518 strcpyW(lpszDest + cchMax, szEllipses);
1519 return TRUE;
1520 }
1521 /* We have a root in the path */
1522 lpszFile--; /* Start compacted filename with the path separator */
1523 dwFileLen++;
1524
1525 if (dwFileLen + 3 > cchMax)
1526 {
1527 /* Compact the file name */
1528 if (cchMax <= 4)
1529 {
1530 while (--cchMax > 0) /* No room left for anything but ellipses */
1531 *lpszDest++ = '.';
1532 *lpszDest = '\0';
1533 return TRUE;
1534 }
1535 strcpyW(lpszDest, szEllipses);
1536 lpszDest += 3;
1537 cchMax -= 4;
1538 *lpszDest++ = *lpszFile++;
1539 if (cchMax <= 4)
1540 {
1541 while (--cchMax > 0) /* No room left for anything but ellipses */
1542 *lpszDest++ = '.';
1543 *lpszDest = '\0';
1544 return TRUE;
1545 }
1546 cchMax -= 4;
1547 memcpy(lpszDest, lpszFile, cchMax * sizeof(WCHAR));
1548 strcpyW(lpszDest + cchMax, szEllipses);
1549 return TRUE;
1550 }
1551
1552 /* Only the root needs to be Compacted */
1553 dwLen = cchMax - dwFileLen - 3;
1554 memcpy(lpszDest, lpszPath, dwLen * sizeof(WCHAR));
1555 strcpyW(lpszDest + dwLen, szEllipses);
1556 strcpyW(lpszDest + dwLen + 3, lpszFile);
1557 return TRUE;
1558}
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1701

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

◆ PathCompactPathW()

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

Definition at line 2938 of file path.c.

2939{
2940 static const WCHAR szEllipses[] = { '.', '.', '.', '\0' };
2941 BOOL bRet = TRUE;
2942 HDC hdc = 0;
2944 SIZE size;
2945 DWORD dwLen;
2946
2947 TRACE("(%p,%s,%d)\n", hDC, debugstr_w(lpszPath), dx);
2948
2949 if (!lpszPath)
2950 return FALSE;
2951
2952 if (!hDC)
2953 hdc = hDC = GetDC(0);
2954
2955 /* Get the length of the whole path */
2956 dwLen = strlenW(lpszPath);
2957 GetTextExtentPointW(hDC, lpszPath, dwLen, &size);
2958
2959 if ((UINT)size.cx > dx)
2960 {
2961 /* Path too big, must reduce it */
2962 LPWSTR sFile;
2963 DWORD dwEllipsesLen = 0, dwPathLen = 0;
2964
2965 sFile = PathFindFileNameW(lpszPath);
2966 if (sFile != lpszPath) sFile--;
2967
2968 /* Get the size of ellipses */
2969 GetTextExtentPointW(hDC, szEllipses, 3, &size);
2970 dwEllipsesLen = size.cx;
2971 /* Get the size of the file name */
2972 GetTextExtentPointW(hDC, sFile, strlenW(sFile), &size);
2973 dwPathLen = size.cx;
2974
2975 if (sFile != lpszPath)
2976 {
2977 LPWSTR sPath = sFile;
2978 BOOL bEllipses = FALSE;
2979
2980 /* The path includes a file name. Include as much of the path prior to
2981 * the file name as possible, allowing for the ellipses, e.g:
2982 * c:\some very long path\filename ==> c:\some v...\filename
2983 */
2984 lstrcpynW(buff, sFile, MAX_PATH);
2985
2986 do
2987 {
2988 DWORD dwTotalLen = bEllipses? dwPathLen + dwEllipsesLen : dwPathLen;
2989
2990 GetTextExtentPointW(hDC, lpszPath, sPath - lpszPath, &size);
2991 dwTotalLen += size.cx;
2992 if (dwTotalLen <= dx)
2993 break;
2994 sPath--;
2995 if (!bEllipses)
2996 {
2997 bEllipses = TRUE;
2998 sPath -= 2;
2999 }
3000 } while (sPath > lpszPath);
3001
3002 if (sPath > lpszPath)
3003 {
3004 if (bEllipses)
3005 {
3006 strcpyW(sPath, szEllipses);
3007 strcpyW(sPath+3, buff);
3008 }
3009 bRet = TRUE;
3010 goto end;
3011 }
3012 strcpyW(lpszPath, szEllipses);
3013 strcpyW(lpszPath+3, buff);
3014 bRet = FALSE;
3015 goto end;
3016 }
3017
3018 /* Trim the path by adding ellipses to the end, e.g:
3019 * A very long file name.txt ==> A very...
3020 */
3021 dwLen = strlenW(lpszPath);
3022
3023 if (dwLen > MAX_PATH - 3)
3024 dwLen = MAX_PATH - 3;
3025 lstrcpynW(buff, sFile, dwLen);
3026
3027 do {
3028 dwLen--;
3029 GetTextExtentPointW(hDC, buff, dwLen, &size);
3030 } while (dwLen && size.cx + dwEllipsesLen > dx);
3031
3032 if (!dwLen)
3033 {
3034 DWORD dwWritten = 0;
3035
3036 dwEllipsesLen /= 3; /* Size of a single '.' */
3037
3038 /* Write as much of the Ellipses string as possible */
3039 while (dwWritten + dwEllipsesLen < dx && dwLen < 3)
3040 {
3041 *lpszPath++ = '.';
3042 dwWritten += dwEllipsesLen;
3043 dwLen++;
3044 }
3045 *lpszPath = '\0';
3046 bRet = FALSE;
3047 }
3048 else
3049 {
3050 strcpyW(buff + dwLen, szEllipses);
3051 strcpyW(lpszPath, buff);
3052 }
3053 }
3054
3055end:
3056 if (hdc)
3057 ReleaseDC(0, hdc);
3058
3059 return bRet;
3060}
static unsigned char buff[32768]
Definition: fatten.c:17
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
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().

◆ PathCreateFromUrlA()

HRESULT WINAPI PathCreateFromUrlA ( LPCSTR  pszUrl,
LPSTR  pszPath,
LPDWORD  pcchPath,
DWORD  dwReserved 
)

Definition at line 3353 of file path.c.

3355{
3356 WCHAR bufW[MAX_PATH];
3357 WCHAR *pathW = bufW;
3358 UNICODE_STRING urlW;
3359 HRESULT ret;
3360 DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
3361
3362 if (!pszUrl || !pszPath || !pcchPath || !*pcchPath)
3363 return E_INVALIDARG;
3364
3365 if(!RtlCreateUnicodeStringFromAsciiz(&urlW, pszUrl))
3366 return E_INVALIDARG;
3367 if((ret = PathCreateFromUrlW(urlW.Buffer, pathW, &lenW, dwReserved)) == E_POINTER) {
3368 pathW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
3369 ret = PathCreateFromUrlW(urlW.Buffer, pathW, &lenW, dwReserved);
3370 }
3371 if(ret == S_OK) {
3372 RtlUnicodeToMultiByteSize(&lenA, pathW, lenW * sizeof(WCHAR));
3373 if(*pcchPath > lenA) {
3374 RtlUnicodeToMultiByteN(pszPath, *pcchPath - 1, &lenA, pathW, lenW * sizeof(WCHAR));
3375 pszPath[lenA] = 0;
3376 *pcchPath = lenA;
3377 } else {
3378 *pcchPath = lenA + 1;
3379 ret = E_POINTER;
3380 }
3381 }
3382 if(pathW != bufW) HeapFree(GetProcessHeap(), 0, pathW);
3383 RtlFreeUnicodeString(&urlW);
3384 return ret;
3385}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define HeapFree(x, y, z)
Definition: compat.h:735
HRESULT WINAPI PathCreateFromUrlW(const WCHAR *url, WCHAR *path, DWORD *pcchPath, DWORD dwReserved)
Definition: path.c:3073
#define S_OK
Definition: intsafe.h:52
static LPWSTR PDWORD pcchPath
Definition: asmcache.c:747
static const WCHAR pathW[]
Definition: path.c:2368
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToMultiByteN(_Out_ PCHAR MbString, _In_ ULONG MbSize, _Out_opt_ PULONG ResultSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:108
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToMultiByteSize(_Out_ PULONG MbSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:146
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define E_POINTER
Definition: winerror.h:3480

◆ PathCreateFromUrlAlloc()

HRESULT WINAPI PathCreateFromUrlAlloc ( LPCWSTR  pszUrl,
LPWSTR pszPath,
DWORD  dwReserved 
)

Definition at line 3544 of file path.c.

3546{
3548 DWORD size;
3549 HRESULT hr;
3550
3551 size = MAX_PATH;
3553 if (SUCCEEDED(hr))
3554 {
3555 /* Yes, this is supposed to crash if pszPath is NULL */
3556 *pszPath = StrDupW(pathW);
3557 }
3558 return hr;
3559}
HRESULT hr
Definition: delayimp.cpp:582
WCHAR *WINAPI StrDupW(const WCHAR *str)
Definition: string.c:313
#define SUCCEEDED(hr)
Definition: intsafe.h:50

◆ PathCreateFromUrlW()

HRESULT WINAPI PathCreateFromUrlW ( LPCWSTR  pszUrl,
LPWSTR  pszPath,
LPDWORD  pcchPath,
DWORD  dwReserved 
)

Definition at line 3402 of file path.c.

3404{
3405 static const WCHAR file_colon[] = { 'f','i','l','e',':',0 };
3406 static const WCHAR localhost[] = { 'l','o','c','a','l','h','o','s','t',0 };
3407 DWORD nslashes, unescape, len;
3408 const WCHAR *src;
3409 WCHAR *tpath, *dst;
3410 HRESULT ret;
3411
3412 TRACE("(%s,%p,%p,0x%08x)\n", debugstr_w(pszUrl), pszPath, pcchPath, dwReserved);
3413
3414 if (!pszUrl || !pszPath || !pcchPath || !*pcchPath)
3415 return E_INVALIDARG;
3416
3417 if (lstrlenW(pszUrl) < 5)
3418 return E_INVALIDARG;
3419
3421 file_colon, 5) != CSTR_EQUAL)
3422 return E_INVALIDARG;
3423 pszUrl += 5;
3424 ret = S_OK;
3425
3426 src = pszUrl;
3427 nslashes = 0;
3428 while (*src == '/' || *src == '\\') {
3429 nslashes++;
3430 src++;
3431 }
3432
3433 /* We need a temporary buffer so we can compute what size to ask for.
3434 * We know that the final string won't be longer than the current pszUrl
3435 * plus at most two backslashes. All the other transformations make it
3436 * shorter.
3437 */
3438 len = 2 + lstrlenW(pszUrl) + 1;
3439 if (*pcchPath < len)
3440 tpath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3441 else
3442 tpath = pszPath;
3443
3444 len = 0;
3445 dst = tpath;
3446 unescape = 1;
3447 switch (nslashes)
3448 {
3449 case 0:
3450 /* 'file:' + escaped DOS path */
3451 break;
3452 case 1:
3453 /* 'file:/' + escaped DOS path */
3454 /* fall through */
3455 case 3:
3456 /* 'file:///' (implied localhost) + escaped DOS path */
3457 if (!isalphaW(*src) || (src[1] != ':' && src[1] != '|'))
3458 src -= 1;
3459 break;
3460 case 2:
3462 src, 9, localhost, 9) == CSTR_EQUAL && (src[9] == '/' || src[9] == '\\'))
3463 {
3464 /* 'file://localhost/' + escaped DOS path */
3465 src += 10;
3466 }
3467 else if (isalphaW(*src) && (src[1] == ':' || src[1] == '|'))
3468 {
3469 /* 'file://' + unescaped DOS path */
3470 unescape = 0;
3471 }
3472 else
3473 {
3474 /* 'file://hostname:port/path' (where path is escaped)
3475 * or 'file:' + escaped UNC path (\\server\share\path)
3476 * The second form is clearly specific to Windows and it might
3477 * even be doing a network lookup to try to figure it out.
3478 */
3479 while (*src && *src != '/' && *src != '\\')
3480 src++;
3481 len = src - pszUrl;
3482 StrCpyNW(dst, pszUrl, len + 1);
3483 dst += len;
3484 if (*src && isalphaW(src[1]) && (src[2] == ':' || src[2] == '|'))
3485 {
3486 /* 'Forget' to add a trailing '/', just like Windows */
3487 src++;
3488 }
3489 }
3490 break;
3491 case 4:
3492 /* 'file://' + unescaped UNC path (\\server\share\path) */
3493 unescape = 0;
3494 if (isalphaW(*src) && (src[1] == ':' || src[1] == '|'))
3495 break;
3496 /* fall through */
3497 default:
3498 /* 'file:/...' + escaped UNC path (\\server\share\path) */
3499 src -= 2;
3500 }
3501
3502 /* Copy the remainder of the path */
3503 len += lstrlenW(src);
3504 StrCpyW(dst, src);
3505
3506 /* First do the Windows-specific path conversions */
3507 for (dst = tpath; *dst; dst++)
3508 if (*dst == '/') *dst = '\\';
3509 if (isalphaW(*tpath) && tpath[1] == '|')
3510 tpath[1] = ':'; /* c| -> c: */
3511
3512 /* And only then unescape the path (i.e. escaped slashes are left as is) */
3513 if (unescape)
3514 {
3516 if (ret == S_OK)
3517 {
3518 /* When working in-place UrlUnescapeW() does not set len */
3519 len = lstrlenW(tpath);
3520 }
3521 }
3522
3523 if (*pcchPath < len + 1)
3524 {
3525 ret = E_POINTER;
3526 *pcchPath = len + 1;
3527 }
3528 else
3529 {
3530 *pcchPath = len;
3531 if (tpath != pszPath)
3532 StrCpyW(pszPath, tpath);
3533 }
3534 if (tpath != pszPath)
3535 HeapFree(GetProcessHeap(), 0, tpath);
3536
3537 TRACE("Returning (%u) %s\n", *pcchPath, debugstr_w(pszPath));
3538 return ret;
3539}
#define lstrlenW
Definition: compat.h:750
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:3946
HRESULT WINAPI UrlUnescapeW(WCHAR *url, WCHAR *unescaped, DWORD *unescaped_len, DWORD flags)
Definition: path.c:2936
WCHAR *WINAPI StrCpyNW(WCHAR *dst, const WCHAR *src, int count)
Definition: string.c:462
LPWSTR WINAPI StrCpyW(LPWSTR lpszStr, LPCWSTR lpszSrc)
Definition: string.c:514
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
BOOL unescape(WCHAR *str, size_t *len)
Definition: lex.c:227
static const BYTE localhost[]
Definition: encode.c:1391
#define LOCALE_INVARIANT
#define URL_UNESCAPE_INPLACE
Definition: shlwapi.h:525
#define isalphaW(n)
Definition: unicode.h:48
#define NORM_IGNORECASE
Definition: winnls.h:187
#define CSTR_EQUAL
Definition: winnls.h:500

◆ PathFileExistsA()

BOOL WINAPI PathFileExistsA ( LPCSTR  lpszPath)

Definition at line 1802 of file path.c.

1803{
1804 UINT iPrevErrMode;
1805 DWORD dwAttr;
1806
1807 TRACE("(%s)\n",debugstr_a(lpszPath));
1808
1809 if (!lpszPath)
1810 return FALSE;
1811
1812 /* Prevent a dialog box if path is on a disk that has been ejected. */
1813 iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1814 dwAttr = GetFileAttributesA(lpszPath);
1815 SetErrorMode(iPrevErrMode);
1816 return dwAttr != INVALID_FILE_ATTRIBUTES;
1817}
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

◆ PathFileExistsAndAttributesA()

BOOL WINAPI PathFileExistsAndAttributesA ( LPCSTR  lpszPath,
DWORD dwAttr 
)

Definition at line 1853 of file path.c.

1854{
1855 UINT iPrevErrMode;
1856 DWORD dwVal = 0;
1857
1858 TRACE("(%s %p)\n", debugstr_a(lpszPath), dwAttr);
1859
1860 if (dwAttr)
1861 *dwAttr = INVALID_FILE_ATTRIBUTES;
1862
1863 if (!lpszPath)
1864 return FALSE;
1865
1866 iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1867 dwVal = GetFileAttributesA(lpszPath);
1868 SetErrorMode(iPrevErrMode);
1869 if (dwAttr)
1870 *dwAttr = dwVal;
1871 return (dwVal != INVALID_FILE_ATTRIBUTES);
1872}

◆ PathFileExistsAndAttributesW()

BOOL WINAPI PathFileExistsAndAttributesW ( LPCWSTR  lpszPath,
DWORD dwAttr 
)

Definition at line 1879 of file path.c.

1880{
1881 UINT iPrevErrMode;
1882 DWORD dwVal;
1883
1884 TRACE("(%s %p)\n", debugstr_w(lpszPath), dwAttr);
1885
1886 if (!lpszPath)
1887 return FALSE;
1888
1889 iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1890 dwVal = GetFileAttributesW(lpszPath);
1891 SetErrorMode(iPrevErrMode);
1892 if (dwAttr)
1893 *dwAttr = dwVal;
1894 return (dwVal != INVALID_FILE_ATTRIBUTES);
1895}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636

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

◆ PathFileExistsDefExtA()

BOOL WINAPI PathFileExistsDefExtA ( LPSTR  lpszPath,
DWORD  dwWhich 
)

Definition at line 1204 of file path.c.

1205{
1206 BOOL bRet = FALSE;
1207
1208 TRACE("(%s,%d)\n", debugstr_a(lpszPath), dwWhich);
1209
1210 if (lpszPath)
1211 {
1214 bRet = PathFileExistsDefExtW(szPath, dwWhich);
1215 if (bRet)
1216 WideCharToMultiByte(CP_ACP,0,szPath,-1,lpszPath,MAX_PATH,0,0);
1217 }
1218 return bRet;
1219}
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1126

◆ PathFileExistsDefExtW()

BOOL WINAPI PathFileExistsDefExtW ( LPWSTR  lpszPath,
DWORD  dwWhich 
)

Definition at line 1126 of file path.c.

1127{
1128 static const WCHAR pszExts[][5] = { { '.', 'p', 'i', 'f', 0},
1129 { '.', 'c', 'o', 'm', 0},
1130 { '.', 'e', 'x', 'e', 0},
1131 { '.', 'b', 'a', 't', 0},
1132 { '.', 'l', 'n', 'k', 0},
1133 { '.', 'c', 'm', 'd', 0},
1134 { 0, 0, 0, 0, 0} };
1135
1136 TRACE("(%s,%d)\n", debugstr_w(lpszPath), dwWhich);
1137
1138 if (!lpszPath || PathIsUNCServerW(lpszPath) || PathIsUNCServerShareW(lpszPath))
1139 return FALSE;
1140
1141 if (dwWhich)
1142 {
1143 LPCWSTR szExt = PathFindExtensionW(lpszPath);
1144#ifndef __REACTOS__
1145 if (!*szExt || dwWhich & 0x40)
1146#else
1147 if (!*szExt || dwWhich & WHICH_OPTIONAL)
1148#endif
1149 {
1150 size_t iChoose = 0;
1151 int iLen = lstrlenW(lpszPath);
1152 if (iLen > (MAX_PATH - 5))
1153 return FALSE;
1154#ifndef __REACTOS__
1155 while ( (dwWhich & 0x1) && pszExts[iChoose][0] )
1156#else
1157 while (pszExts[iChoose][0])
1158#endif
1159 {
1160#ifdef __REACTOS__
1161 if (dwWhich & 0x1)
1162 {
1164#endif
1165 lstrcpyW(lpszPath + iLen, pszExts[iChoose]);
1166 if (PathFileExistsW(lpszPath))
1167 return TRUE;
1168#ifdef __REACTOS__
1169 }
1170#endif
1171 iChoose++;
1172 dwWhich >>= 1;
1173 }
1174 *(lpszPath + iLen) = (WCHAR)'\0';
1175 return FALSE;
1176 }
1177 }
1178 return PathFileExistsW(lpszPath);
1179}
#define lstrcpyW
Definition: compat.h:749
BOOL WINAPI PathIsUNCServerW(LPCWSTR lpszPath)
Definition: path.c:2370
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1824
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define WHICH_OPTIONAL
#define GetFileAttributes
Definition: winbase.h:3564

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

◆ PathFileExistsW()

BOOL WINAPI PathFileExistsW ( LPCWSTR  lpszPath)

Definition at line 1824 of file path.c.

1825{
1826 UINT iPrevErrMode;
1827 DWORD dwAttr;
1828
1829 TRACE("(%s)\n",debugstr_w(lpszPath));
1830
1831 if (!lpszPath)
1832 return FALSE;
1833
1834 iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1835 dwAttr = GetFileAttributesW(lpszPath);
1836 SetErrorMode(iPrevErrMode);
1837 return dwAttr != INVALID_FILE_ATTRIBUTES;
1838}

◆ PathFindExtensionA()

LPSTR WINAPI PathFindExtensionA ( LPCSTR  lpszPath)

Definition at line 425 of file path.c.

426{
427 LPCSTR lastpoint = NULL;
428
429 TRACE("(%s)\n", debugstr_a(lpszPath));
430
431 if (lpszPath)
432 {
433 while (*lpszPath)
434 {
435 if (*lpszPath == '\\' || *lpszPath==' ')
436 lastpoint = NULL;
437 else if (*lpszPath == '.')
438 lastpoint = lpszPath;
439 lpszPath = CharNextA(lpszPath);
440 }
441 }
442 return (LPSTR)(lastpoint ? lastpoint : lpszPath);
443}

◆ PathFindExtensionW()

LPWSTR WINAPI PathFindExtensionW ( LPCWSTR  lpszPath)

Definition at line 450 of file path.c.

451{
452 LPCWSTR lastpoint = NULL;
453
454 TRACE("(%s)\n", debugstr_w(lpszPath));
455
456 if (lpszPath)
457 {
458 while (*lpszPath)
459 {
460 if (*lpszPath == '\\' || *lpszPath==' ')
461 lastpoint = NULL;
462 else if (*lpszPath == '.')
463 lastpoint = lpszPath;
464 lpszPath++;
465 }
466 }
467 return (LPWSTR)(lastpoint ? lastpoint : lpszPath);
468}

◆ PathFindFileNameA()

LPSTR WINAPI PathFindFileNameA ( LPCSTR  lpszPath)

Definition at line 376 of file path.c.

377{
378 LPCSTR lastSlash = lpszPath;
379
380 TRACE("(%s)\n",debugstr_a(lpszPath));
381
382 while (lpszPath && *lpszPath)
383 {
384 if ((*lpszPath == '\\' || *lpszPath == '/' || *lpszPath == ':') &&
385 lpszPath[1] && lpszPath[1] != '\\' && lpszPath[1] != '/')
386 lastSlash = lpszPath + 1;
387 lpszPath = CharNextA(lpszPath);
388 }
389 return (LPSTR)lastSlash;
390}

◆ PathFindFileNameW()

LPWSTR WINAPI PathFindFileNameW ( LPCWSTR  lpszPath)

Definition at line 397 of file path.c.

398{
399 LPCWSTR lastSlash = lpszPath;
400
401 TRACE("(%s)\n",debugstr_w(lpszPath));
402
403 while (lpszPath && *lpszPath)
404 {
405 if ((*lpszPath == '\\' || *lpszPath == '/' || *lpszPath == ':') &&
406 lpszPath[1] && lpszPath[1] != '\\' && lpszPath[1] != '/')
407 lastSlash = lpszPath + 1;
408 lpszPath++;
409 }
410 return (LPWSTR)lastSlash;
411}

◆ PathFindNextComponentA()

LPSTR WINAPI PathFindNextComponentA ( LPCSTR  lpszPath)

Definition at line 2603 of file path.c.

2604{
2605 LPSTR lpszSlash;
2606
2607 TRACE("(%s)\n", debugstr_a(lpszPath));
2608
2609 if(!lpszPath || !*lpszPath)
2610 return NULL;
2611
2612 if ((lpszSlash = StrChrA(lpszPath, '\\')))
2613 {
2614 if (lpszSlash[1] == '\\')
2615 lpszSlash++;
2616 return lpszSlash + 1;
2617 }
2618 return (LPSTR)lpszPath + strlen(lpszPath);
2619}
LPSTR WINAPI StrChrA(LPCSTR lpszStr, WORD ch)
Definition: string.c:266

◆ PathFindNextComponentW()

LPWSTR WINAPI PathFindNextComponentW ( LPCWSTR  lpszPath)

Definition at line 2626 of file path.c.

2627{
2628 LPWSTR lpszSlash;
2629
2630 TRACE("(%s)\n", debugstr_w(lpszPath));
2631
2632 if(!lpszPath || !*lpszPath)
2633 return NULL;
2634
2635 if ((lpszSlash = StrChrW(lpszPath, '\\')))
2636 {
2637 if (lpszSlash[1] == '\\')
2638 lpszSlash++;
2639 return lpszSlash + 1;
2640 }
2641 return (LPWSTR)lpszPath + strlenW(lpszPath);
2642}
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:464

◆ PathFindOnPathA()

BOOL WINAPI PathFindOnPathA ( LPSTR  lpszFile,
LPCSTR lppszOtherDirs 
)

Definition at line 1401 of file path.c.

1402{
1403 TRACE("(%s,%p)\n", debugstr_a(lpszFile), lppszOtherDirs);
1404 return PathFindOnPathExA(lpszFile, lppszOtherDirs, 0);
1405 }
BOOL WINAPI PathFindOnPathExA(LPSTR lpszFile, LPCSTR *lppszOtherDirs, DWORD dwWhich)
Definition: path.c:1316

◆ PathFindOnPathExA()

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

Definition at line 1316 of file path.c.

1317{
1318 WCHAR szFile[MAX_PATH];
1320
1321 TRACE("(%s,%p,%08x)\n", debugstr_a(lpszFile), lppszOtherDirs, dwWhich);
1322
1323 if (!lpszFile || !PathIsFileSpecA(lpszFile))
1324 return FALSE;
1325
1326 MultiByteToWideChar(CP_ACP,0,lpszFile,-1,szFile,MAX_PATH);
1327
1328 /* Search provided directories first */
1329 if (lppszOtherDirs && *lppszOtherDirs)
1330 {
1331 WCHAR szOther[MAX_PATH];
1332 LPCSTR *lpszOtherPath = lppszOtherDirs;
1333
1334 while (lpszOtherPath && *lpszOtherPath && (*lpszOtherPath)[0])
1335 {
1336 MultiByteToWideChar(CP_ACP,0,*lpszOtherPath,-1,szOther,MAX_PATH);
1337 PathCombineW(buff, szOther, szFile);
1338 if (PathFileExistsDefExtW(buff, dwWhich))
1339 {
1340 WideCharToMultiByte(CP_ACP,0,buff,-1,lpszFile,MAX_PATH,0,0);
1341 return TRUE;
1342 }
1343 lpszOtherPath++;
1344 }
1345 }
1346 /* Not found, try system and path dirs */
1347 if (SHLWAPI_PathFindInOtherDirs(szFile, dwWhich))
1348 {
1349 WideCharToMultiByte(CP_ACP,0,szFile,-1,lpszFile,MAX_PATH,0,0);
1350 return TRUE;
1351 }
1352 return FALSE;
1353}
static BOOL SHLWAPI_PathFindInOtherDirs(LPWSTR lpszFile, DWORD dwWhich)
Definition: path.c:1226
BOOL WINAPI PathIsFileSpecA(LPCSTR lpszPath)
Definition: path.c:2159

Referenced by PathFindOnPathA().

◆ PathFindOnPathExW()

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

Definition at line 1360 of file path.c.

1361{
1363
1364 TRACE("(%s,%p,%08x)\n", debugstr_w(lpszFile), lppszOtherDirs, dwWhich);
1365
1366 if (!lpszFile || !PathIsFileSpecW(lpszFile))
1367 return FALSE;
1368
1369 /* Search provided directories first */
1370 if (lppszOtherDirs && *lppszOtherDirs)
1371 {
1372 LPCWSTR *lpszOtherPath = lppszOtherDirs;
1373 while (lpszOtherPath && *lpszOtherPath && (*lpszOtherPath)[0])
1374 {
1375 PathCombineW(buff, *lpszOtherPath, lpszFile);
1376 if (PathFileExistsDefExtW(buff, dwWhich))
1377 {
1378 strcpyW(lpszFile, buff);
1379 return TRUE;
1380 }
1381 lpszOtherPath++;
1382 }
1383 }
1384 /* Not found, try system and path dirs */
1385 return SHLWAPI_PathFindInOtherDirs(lpszFile, dwWhich);
1386}
BOOL WINAPI PathIsFileSpecW(LPCWSTR lpszPath)
Definition: path.c:2180

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

◆ PathFindOnPathW()

BOOL WINAPI PathFindOnPathW ( LPWSTR  lpszFile,
LPCWSTR lppszOtherDirs 
)

Definition at line 1412 of file path.c.

1413{
1414 TRACE("(%s,%p)\n", debugstr_w(lpszFile), lppszOtherDirs);
1415 return PathFindOnPathExW(lpszFile,lppszOtherDirs, 0);
1416}
BOOL WINAPI PathFindOnPathExW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs, DWORD dwWhich)
Definition: path.c:1360

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

◆ PathFindSuffixArrayA()

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

Definition at line 4040 of file path.c.

4041{
4042 size_t dwLen;
4043 int dwRet = 0;
4044
4045 TRACE("(%s,%p,%d)\n",debugstr_a(lpszSuffix), lppszArray, dwCount);
4046
4047 if (lpszSuffix && lppszArray && dwCount > 0)
4048 {
4049 dwLen = strlen(lpszSuffix);
4050
4051 while (dwRet < dwCount)
4052 {
4053 size_t dwCompareLen = strlen(*lppszArray);
4054 if (dwCompareLen < dwLen)
4055 {
4056 if (!strcmp(lpszSuffix + dwLen - dwCompareLen, *lppszArray))
4057 return *lppszArray; /* Found */
4058 }
4059 dwRet++;
4060 lppszArray++;
4061 }
4062 }
4063 return NULL;
4064}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319

◆ PathFindSuffixArrayW()

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

Definition at line 4071 of file path.c.

4072{
4073 size_t dwLen;
4074 int dwRet = 0;
4075
4076 TRACE("(%s,%p,%d)\n",debugstr_w(lpszSuffix), lppszArray, dwCount);
4077
4078 if (lpszSuffix && lppszArray && dwCount > 0)
4079 {
4080 dwLen = strlenW(lpszSuffix);
4081
4082 while (dwRet < dwCount)
4083 {
4084 size_t dwCompareLen = strlenW(*lppszArray);
4085 if (dwCompareLen < dwLen)
4086 {
4087 if (!strcmpW(lpszSuffix + dwLen - dwCompareLen, *lppszArray))
4088 return *lppszArray; /* Found */
4089 }
4090 dwRet++;
4091 lppszArray++;
4092 }
4093 }
4094 return NULL;
4095}
#define strcmpW(s1, s2)
Definition: unicode.h:38

◆ PathGetArgsA()

LPSTR WINAPI PathGetArgsA ( LPCSTR  lpszPath)

Definition at line 484 of file path.c.

485{
486 BOOL bSeenQuote = FALSE;
487
488 TRACE("(%s)\n",debugstr_a(lpszPath));
489
490 if (lpszPath)
491 {
492 while (*lpszPath)
493 {
494 if ((*lpszPath==' ') && !bSeenQuote)
495 return (LPSTR)lpszPath + 1;
496 if (*lpszPath == '"')
497 bSeenQuote = !bSeenQuote;
498 lpszPath = CharNextA(lpszPath);
499 }
500 }
501 return (LPSTR)lpszPath;
502}

◆ PathGetArgsW()

LPWSTR WINAPI PathGetArgsW ( LPCWSTR  lpszPath)

Definition at line 509 of file path.c.

510{
511 BOOL bSeenQuote = FALSE;
512
513 TRACE("(%s)\n",debugstr_w(lpszPath));
514
515 if (lpszPath)
516 {
517 while (*lpszPath)
518 {
519 if ((*lpszPath==' ') && !bSeenQuote)
520 return (LPWSTR)lpszPath + 1;
521 if (*lpszPath == '"')
522 bSeenQuote = !bSeenQuote;
523 lpszPath++;
524 }
525 }
526 return (LPWSTR)lpszPath;
527}

◆ PathGetCharTypeA()

UINT WINAPI PathGetCharTypeA ( UCHAR  ch)

Definition at line 3073 of file path.c.

3074{
3075 return PathGetCharTypeW(ch);
3076}
UINT WINAPI PathGetCharTypeW(WCHAR ch)
Definition: path.c:1762
unsigned char ch[4][2]
Definition: console.c:118

◆ PathGetCharTypeW()

UINT WINAPI PathGetCharTypeW ( WCHAR  ch)

Definition at line 3083 of file path.c.

3084{
3085 UINT flags = 0;
3086
3087 TRACE("(%d)\n", ch);
3088
3089 if (!ch || ch < ' ' || ch == '<' || ch == '>' ||
3090 ch == '"' || ch == '|' || ch == '/')
3091 flags = GCT_INVALID; /* Invalid */
3092 else if (ch == '*' || ch=='?')
3093 flags = GCT_WILD; /* Wildchars */
3094 else if ((ch == '\\') || (ch == ':'))
3095 return GCT_SEPARATOR; /* Path separators */
3096 else
3097 {
3098 if (ch < 126)
3099 {
3100 if (((ch & 0x1) && ch != ';') || !ch || isalnum(ch) || ch == '$' || ch == '&' || ch == '(' ||
3101 ch == '.' || ch == '@' || ch == '^' ||
3102 ch == '\'' || ch == 130 || ch == '`')
3103 flags |= GCT_SHORTCHAR; /* All these are valid for DOS */
3104 }
3105 else
3106 flags |= GCT_SHORTCHAR; /* Bug compatible with win32 */
3107 flags |= GCT_LFNCHAR; /* Valid for long file names */
3108 }
3109 return flags;
3110}
int CDECL isalnum(int c)
Definition: ctype.c:214
GLbitfield flags
Definition: glext.h:7161
#define GCT_SHORTCHAR
Definition: shlwapi.h:273
#define GCT_LFNCHAR
Definition: shlwapi.h:272
#define GCT_SEPARATOR
Definition: shlwapi.h:275
#define GCT_INVALID
Definition: shlwapi.h:271
#define GCT_WILD
Definition: shlwapi.h:274

◆ PathGetDriveNumberA()

int WINAPI PathGetDriveNumberA ( LPCSTR  lpszPath)

Definition at line 541 of file path.c.

542{
543 TRACE ("(%s)\n",debugstr_a(lpszPath));
544
545 if (lpszPath && !IsDBCSLeadByte(*lpszPath) && lpszPath[1] == ':' &&
546 tolower(*lpszPath) >= 'a' && tolower(*lpszPath) <= 'z')
547 return tolower(*lpszPath) - 'a';
548 return -1;
549}
BOOL WINAPI IsDBCSLeadByte(BYTE testchar)
Definition: locale.c:2126

◆ PathGetDriveNumberW()

int WINAPI PathGetDriveNumberW ( const WCHAR path)

Definition at line 556 of file path.c.

557{
558 WCHAR drive;
559
560 static const WCHAR nt_prefixW[] = {'\\','\\','?','\\'};
561
562 TRACE("(%s)\n", debugstr_w(path));
563
564 if (!path)
565 return -1;
566
567 if (!strncmpW(path, nt_prefixW, 4))
568 path += 4;
569
570 drive = tolowerW(path[0]);
571 if (drive < 'a' || drive > 'z' || path[1] != ':')
572 return -1;
573
574 return drive - 'a';
575}
#define strncmpW(s1, s2, n)
Definition: unicode.h:36

◆ PathIsContentTypeA()

BOOL WINAPI PathIsContentTypeA ( LPCSTR  lpszPath,
LPCSTR  lpszContentType 
)

Definition at line 2105 of file path.c.

2106{
2107 LPCSTR szExt;
2108 DWORD dwDummy;
2109 char szBuff[MAX_PATH];
2110
2111 TRACE("(%s,%s)\n", debugstr_a(lpszPath), debugstr_a(lpszContentType));
2112
2113 if (lpszPath && (szExt = PathFindExtensionA(lpszPath)) && *szExt &&
2114 !SHGetValueA(HKEY_CLASSES_ROOT, szExt, "Content Type",
2115 REG_NONE, szBuff, &dwDummy) &&
2116 !strcasecmp(lpszContentType, szBuff))
2117 {
2118 return TRUE;
2119 }
2120 return FALSE;
2121}
DWORD WINAPI SHGetValueA(HKEY hKey, LPCSTR lpszSubKey, LPCSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1249
#define strcasecmp
Definition: fake.h:9
#define REG_NONE
Definition: nt_native.h:1495
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

◆ PathIsContentTypeW()

BOOL WINAPI PathIsContentTypeW ( LPCWSTR  lpszPath,
LPCWSTR  lpszContentType 
)

Definition at line 2128 of file path.c.

2129{
2130 static const WCHAR szContentType[] = { 'C','o','n','t','e','n','t',' ','T','y','p','e','\0' };
2131 LPCWSTR szExt;
2132 DWORD dwDummy;
2133 WCHAR szBuff[MAX_PATH];
2134
2135 TRACE("(%s,%s)\n", debugstr_w(lpszPath), debugstr_w(lpszContentType));
2136
2137 if (lpszPath && (szExt = PathFindExtensionW(lpszPath)) && *szExt &&
2138 !SHGetValueW(HKEY_CLASSES_ROOT, szExt, szContentType,
2139 REG_NONE, szBuff, &dwDummy) &&
2140 !strcmpiW(lpszContentType, szBuff))
2141 {
2142 return TRUE;
2143 }
2144 return FALSE;
2145}
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1278
#define strcmpiW(s1, s2)
Definition: unicode.h:39

◆ PathIsDirectoryA()

BOOL WINAPI PathIsDirectoryA ( LPCSTR  lpszPath)

Definition at line 1707 of file path.c.

1708{
1709 DWORD dwAttr;
1710
1711 TRACE("(%s)\n", debugstr_a(lpszPath));
1712
1713 if (!lpszPath || PathIsUNCServerA(lpszPath))
1714 return FALSE;
1715
1716 if (PathIsUNCServerShareA(lpszPath))
1717 {
1718#ifdef __REACTOS__
1719 LPSTR lpSystem = NULL;
1720 BYTE buffer[512] = {0};
1721 DWORD cbBuffer = sizeof(buffer);
1723 DWORD dwError;
1724
1725 pNetRes->dwScope = RESOURCE_GLOBALNET;
1726 pNetRes->dwType = RESOURCETYPE_ANY;
1727 pNetRes->lpRemoteName = (LPSTR)lpszPath;
1728
1729 dwError = WNetGetResourceInformationA(pNetRes, pNetRes, &cbBuffer, &lpSystem);
1730 if (dwError == NO_ERROR && pNetRes->dwDisplayType != RESOURCEDISPLAYTYPE_GENERIC)
1731 {
1732 return (pNetRes->dwDisplayType == RESOURCEDISPLAYTYPE_SHARE) &&
1733 (pNetRes->dwType == RESOURCETYPE_ANY || pNetRes->dwType == RESOURCETYPE_DISK);
1734 }
1735#else
1736 FIXME("UNC Server Share not yet supported - FAILING\n");
1737 return FALSE;
1738#endif
1739 }
1740
1741 if ((dwAttr = GetFileAttributesA(lpszPath)) == INVALID_FILE_ATTRIBUTES)
1742 return FALSE;
1743 return dwAttr & FILE_ATTRIBUTE_DIRECTORY;
1744}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define NO_ERROR
Definition: dderror.h:5
BOOL WINAPI PathIsUNCServerA(LPCSTR lpszPath)
Definition: path.c:2348
BOOL WINAPI PathIsUNCServerShareA(LPCSTR lpszPath)
Definition: path.c:2398
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
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 3958 of file path.c.

3959{
3960 BOOL bRet = FALSE;
3961
3962 TRACE("(%s)\n",debugstr_a(lpszPath));
3963
3964 if (lpszPath)
3965 {
3969 }
3970 return bRet;
3971}
BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath)
Definition: path.c:3978

◆ PathIsDirectoryEmptyW()

BOOL WINAPI PathIsDirectoryEmptyW ( LPCWSTR  lpszPath)

Definition at line 3978 of file path.c.

3979{
3980 static const WCHAR szAllFiles[] = { '*', '.', '*', '\0' };
3981 WCHAR szSearch[MAX_PATH];
3982 DWORD dwLen;
3983 HANDLE hfind;
3984 BOOL retVal = TRUE;
3986
3987 TRACE("(%s)\n",debugstr_w(lpszPath));
3988
3989 if (!lpszPath || !PathIsDirectoryW(lpszPath))
3990 return FALSE;
3991
3992 lstrcpynW(szSearch, lpszPath, MAX_PATH);
3993 PathAddBackslashW(szSearch);
3994 dwLen = strlenW(szSearch);
3995 if (dwLen > MAX_PATH - 4)
3996 return FALSE;
3997
3998 strcpyW(szSearch + dwLen, szAllFiles);
3999 hfind = FindFirstFileW(szSearch, &find_data);
4000 if (hfind == INVALID_HANDLE_VALUE)
4001 return FALSE;
4002
4003 do
4004 {
4005 if (find_data.cFileName[0] == '.')
4006 {
4007 if (find_data.cFileName[1] == '\0') continue;
4008 if (find_data.cFileName[1] == '.' && find_data.cFileName[2] == '\0') continue;
4009 }
4010
4011 retVal = FALSE;
4012 break;
4013 }
4014 while (FindNextFileW(hfind, &find_data));
4015
4016 FindClose(hfind);
4017 return retVal;
4018}
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:1751

Referenced by move_dir_to_dir(), and PathIsDirectoryEmptyA().

◆ PathIsDirectoryW()

BOOL WINAPI PathIsDirectoryW ( LPCWSTR  lpszPath)

Definition at line 1751 of file path.c.

1752{
1753 DWORD dwAttr;
1754
1755 TRACE("(%s)\n", debugstr_w(lpszPath));
1756
1757 if (!lpszPath || PathIsUNCServerW(lpszPath))
1758 return FALSE;
1759
1760 if (PathIsUNCServerShareW(lpszPath))
1761 {
1762#ifdef __REACTOS__
1763 LPWSTR lpSystem = NULL;
1764 BYTE buffer[1024] = {0};
1765 DWORD cbBuffer = sizeof(buffer);
1767 DWORD dwError;
1768
1769 pNetRes->dwScope = RESOURCE_GLOBALNET;
1770 pNetRes->dwType = RESOURCETYPE_ANY;
1771 pNetRes->lpRemoteName = (LPWSTR)lpszPath;
1772
1773 dwError = WNetGetResourceInformationW(pNetRes, pNetRes, &cbBuffer, &lpSystem);
1774 if (dwError == NO_ERROR && pNetRes->dwDisplayType != RESOURCEDISPLAYTYPE_GENERIC)
1775 {
1776 return (pNetRes->dwDisplayType == RESOURCEDISPLAYTYPE_SHARE) &&
1777 (pNetRes->dwType == RESOURCETYPE_ANY || pNetRes->dwType == RESOURCETYPE_DISK);
1778 }
1779#else
1780 FIXME("UNC Server Share not yet supported - FAILING\n");
1781 return FALSE;
1782#endif
1783 }
1784
1785 if ((dwAttr = GetFileAttributesW(lpszPath)) == INVALID_FILE_ATTRIBUTES)
1786 return FALSE;
1787 return dwAttr & FILE_ATTRIBUTE_DIRECTORY;
1788}
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().

◆ PathIsFileSpecA()

BOOL WINAPI PathIsFileSpecA ( LPCSTR  lpszPath)

Definition at line 2159 of file path.c.

2160{
2161 TRACE("(%s)\n", debugstr_a(lpszPath));
2162
2163 if (!lpszPath)
2164 return FALSE;
2165
2166 while (*lpszPath)
2167 {
2168 if (*lpszPath == '\\' || *lpszPath == ':')
2169 return FALSE;
2170 lpszPath = CharNextA(lpszPath);
2171 }
2172 return TRUE;
2173}

◆ PathIsFileSpecW()

BOOL WINAPI PathIsFileSpecW ( LPCWSTR  lpszPath)

Definition at line 2180 of file path.c.

2181{
2182 TRACE("(%s)\n", debugstr_w(lpszPath));
2183
2184 if (!lpszPath)
2185 return FALSE;
2186
2187 while (*lpszPath)
2188 {
2189 if (*lpszPath == '\\' || *lpszPath == ':')
2190 return FALSE;
2191 lpszPath++;
2192 }
2193 return TRUE;
2194}

◆ PathIsLFNFileSpecA()

BOOL WINAPI PathIsLFNFileSpecA ( LPCSTR  lpszPath)

Definition at line 3869 of file path.c.

3870{
3871 DWORD dwNameLen = 0, dwExtLen = 0;
3872
3873 TRACE("(%s)\n",debugstr_a(lpszPath));
3874
3875 if (!lpszPath)
3876 return FALSE;
3877
3878 while (*lpszPath)
3879 {
3880 if (*lpszPath == ' ')
3881 return TRUE; /* DOS names cannot have spaces */
3882 if (*lpszPath == '.')
3883 {
3884 if (dwExtLen)
3885 return TRUE; /* DOS names have only one dot */
3886 dwExtLen = 1;
3887 }
3888 else if (dwExtLen)
3889 {
3890 dwExtLen++;
3891 if (dwExtLen > 4)
3892 return TRUE; /* DOS extensions are <= 3 chars*/
3893 }
3894 else
3895 {
3896 dwNameLen++;
3897 if (dwNameLen > 8)
3898 return TRUE; /* DOS names are <= 8 chars */
3899 }
3900 lpszPath += IsDBCSLeadByte(*lpszPath) ? 2 : 1;
3901 }
3902 return FALSE; /* Valid DOS path */
3903}

◆ PathIsLFNFileSpecW()

BOOL WINAPI PathIsLFNFileSpecW ( LPCWSTR  lpszPath)

Definition at line 3910 of file path.c.

3911{
3912 DWORD dwNameLen = 0, dwExtLen = 0;
3913
3914 TRACE("(%s)\n",debugstr_w(lpszPath));
3915
3916 if (!lpszPath)
3917 return FALSE;
3918
3919 while (*lpszPath)
3920 {
3921 if (*lpszPath == ' ')
3922 return TRUE; /* DOS names cannot have spaces */
3923 if (*lpszPath == '.')
3924 {
3925 if (dwExtLen)
3926 return TRUE; /* DOS names have only one dot */
3927 dwExtLen = 1;
3928 }
3929 else if (dwExtLen)
3930 {
3931 dwExtLen++;
3932 if (dwExtLen > 4)
3933 return TRUE; /* DOS extensions are <= 3 chars*/
3934 }
3935 else
3936 {
3937 dwNameLen++;
3938 if (dwNameLen > 8)
3939 return TRUE; /* DOS names are <= 8 chars */
3940 }
3941 lpszPath++;
3942 }
3943 return FALSE; /* Valid DOS path */
3944}

◆ PathIsNetworkPathA()

BOOL WINAPI PathIsNetworkPathA ( LPCSTR  lpszPath)

Definition at line 3810 of file path.c.

3811{
3812 int dwDriveNum;
3813
3814 TRACE("(%s)\n",debugstr_a(lpszPath));
3815
3816 if (!lpszPath)
3817 return FALSE;
3818 if (*lpszPath == '\\' && lpszPath[1] == '\\')
3819 return TRUE;
3820 dwDriveNum = PathGetDriveNumberA(lpszPath);
3821 if (dwDriveNum == -1)
3822 return FALSE;
3823#ifdef __REACTOS__
3824 return IsNetDrive(dwDriveNum);
3825#else
3826 GET_FUNC(pIsNetDrive, shell32, (LPCSTR)66, FALSE); /* ord 66 = shell32.IsNetDrive */
3827 return pIsNetDrive(dwDriveNum);
3828#endif
3829}
@ shell32
Definition: LocaleTests.cpp:20
#define GET_FUNC(func, module, name, fail)
Definition: path.c:55
int WINAPI PathGetDriveNumberA(LPCSTR lpszPath)
Definition: path.c:541
static fnpIsNetDrive pIsNetDrive
Definition: path.c:69
EXTERN_C int WINAPI IsNetDrive(int drive)
Definition: shlfileop.cpp:2342

◆ PathIsNetworkPathW()

BOOL WINAPI PathIsNetworkPathW ( LPCWSTR  lpszPath)

Definition at line 3836 of file path.c.

3837{
3838 int dwDriveNum;
3839
3840 TRACE("(%s)\n", debugstr_w(lpszPath));
3841
3842 if (!lpszPath)
3843 return FALSE;
3844 if (*lpszPath == '\\' && lpszPath[1] == '\\')
3845 return TRUE;
3846 dwDriveNum = PathGetDriveNumberW(lpszPath);
3847 if (dwDriveNum == -1)
3848 return FALSE;
3849#ifdef __REACTOS__
3850 return IsNetDrive(dwDriveNum);
3851#else
3852 GET_FUNC(pIsNetDrive, shell32, (LPCSTR)66, FALSE); /* ord 66 = shell32.IsNetDrive */
3853 return pIsNetDrive(dwDriveNum);
3854#endif
3855}
int WINAPI PathGetDriveNumberW(const WCHAR *path)
Definition: path.c:556

◆ PathIsPrefixA()

BOOL WINAPI PathIsPrefixA ( LPCSTR  lpszPrefix,
LPCSTR  lpszPath 
)

Definition at line 2209 of file path.c.

2210{
2211 TRACE("(%s,%s)\n", debugstr_a(lpszPrefix), debugstr_a(lpszPath));
2212
2213 if (lpszPrefix && lpszPath &&
2214 PathCommonPrefixA(lpszPath, lpszPrefix, NULL) == (int)strlen(lpszPrefix))
2215 return TRUE;
2216 return FALSE;
2217}
int WINAPI PathCommonPrefixA(const char *file1, const char *file2, char *path)
Definition: path.c:1570

◆ PathIsPrefixW()

BOOL WINAPI PathIsPrefixW ( LPCWSTR  lpszPrefix,
LPCWSTR  lpszPath 
)

Definition at line 2224 of file path.c.

2225{
2226 TRACE("(%s,%s)\n", debugstr_w(lpszPrefix), debugstr_w(lpszPath));
2227
2228 if (lpszPrefix && lpszPath &&
2229 PathCommonPrefixW(lpszPath, lpszPrefix, NULL) == (int)strlenW(lpszPrefix))
2230 return TRUE;
2231 return FALSE;
2232}
int WINAPI PathCommonPrefixW(const WCHAR *file1, const WCHAR *file2, WCHAR *path)
Definition: path.c:1620

◆ PathIsRelativeA()

BOOL WINAPI PathIsRelativeA ( LPCSTR  lpszPath)

Definition at line 1572 of file path.c.

1573{
1574 TRACE("(%s)\n",debugstr_a(lpszPath));
1575
1576 if (!lpszPath || !*lpszPath || IsDBCSLeadByte(*lpszPath))
1577 return TRUE;
1578 if (*lpszPath == '\\' || (*lpszPath && lpszPath[1] == ':'))
1579 return FALSE;
1580 return TRUE;
1581}

◆ PathIsRelativeW()

BOOL WINAPI PathIsRelativeW ( LPCWSTR  lpszPath)

Definition at line 1588 of file path.c.

1589{
1590 TRACE("(%s)\n",debugstr_w(lpszPath));
1591
1592 if (!lpszPath || !*lpszPath)
1593 return TRUE;
1594 if (*lpszPath == '\\' || (*lpszPath && lpszPath[1] == ':'))
1595 return FALSE;
1596 return TRUE;
1597}

◆ PathIsRootA()

BOOL WINAPI PathIsRootA ( LPCSTR  lpszPath)

Definition at line 1611 of file path.c.

1612{
1613 TRACE("(%s)\n", debugstr_a(lpszPath));
1614
1615 if (lpszPath && *lpszPath)
1616 {
1617 if (*lpszPath == '\\')
1618 {
1619 if (!lpszPath[1])
1620 return TRUE; /* \ */
1621 else if (lpszPath[1]=='\\')
1622 {
1623 BOOL bSeenSlash = FALSE;
1624 lpszPath += 2;
1625
1626 /* Check for UNC root path */
1627 while (*lpszPath)
1628 {
1629 if (*lpszPath == '\\')
1630 {
1631 if (bSeenSlash)
1632 return FALSE;
1633 bSeenSlash = TRUE;
1634 }
1635 lpszPath = CharNextA(lpszPath);
1636 }
1637 return TRUE;
1638 }
1639 }
1640 else if (lpszPath[1] == ':' && lpszPath[2] == '\\' && lpszPath[3] == '\0')
1641 return TRUE; /* X:\ */
1642 }
1643 return FALSE;
1644}

◆ PathIsRootW()

BOOL WINAPI PathIsRootW ( LPCWSTR  lpszPath)

Definition at line 1651 of file path.c.

1652{
1653 TRACE("(%s)\n", debugstr_w(lpszPath));
1654
1655 if (lpszPath && *lpszPath)
1656 {
1657 if (*lpszPath == '\\')
1658 {
1659 if (!lpszPath[1])
1660 return TRUE; /* \ */
1661 else if (lpszPath[1]=='\\')
1662 {
1663 BOOL bSeenSlash = FALSE;
1664 lpszPath += 2;
1665
1666 /* Check for UNC root path */
1667 while (*lpszPath)
1668 {
1669 if (*lpszPath == '\\')
1670 {
1671 if (bSeenSlash)
1672 return FALSE;
1673 bSeenSlash = TRUE;
1674 }
1675 lpszPath++;
1676 }
1677 return TRUE;
1678 }
1679 }
1680 else if (lpszPath[1] == ':' && lpszPath[2] == '\\' && lpszPath[3] == '\0')
1681 return TRUE; /* X:\ */
1682 }
1683 return FALSE;
1684}

◆ PathIsSameRootA()

BOOL WINAPI PathIsSameRootA ( LPCSTR  lpszPath1,
LPCSTR  lpszPath2 
)

Definition at line 2050 of file path.c.

2051{
2052 LPCSTR lpszStart;
2053 int dwLen;
2054
2055 TRACE("(%s,%s)\n", debugstr_a(lpszPath1), debugstr_a(lpszPath2));
2056
2057 if (!lpszPath1 || !lpszPath2 || !(lpszStart = PathSkipRootA(lpszPath1)))
2058 return FALSE;
2059
2060 dwLen = PathCommonPrefixA(lpszPath1, lpszPath2, NULL) + 1;
2061 if (lpszStart - lpszPath1 > dwLen)
2062 return FALSE; /* Paths not common up to length of the root */
2063 return TRUE;
2064}
char *WINAPI PathSkipRootA(const char *path)
Definition: path.c:2267

◆ PathIsSameRootW()

BOOL WINAPI PathIsSameRootW ( LPCWSTR  lpszPath1,
LPCWSTR  lpszPath2 
)

Definition at line 2071 of file path.c.

2072{
2073 LPCWSTR lpszStart;
2074 int dwLen;
2075
2076 TRACE("(%s,%s)\n", debugstr_w(lpszPath1), debugstr_w(lpszPath2));
2077
2078 if (!lpszPath1 || !lpszPath2 || !(lpszStart = PathSkipRootW(lpszPath1)))
2079 return FALSE;
2080
2081 dwLen = PathCommonPrefixW(lpszPath1, lpszPath2, NULL) + 1;
2082 if (lpszStart - lpszPath1 > dwLen)
2083 return FALSE; /* Paths not common up to length of the root */
2084 return TRUE;
2085}
WCHAR *WINAPI PathSkipRootW(const WCHAR *path)
Definition: path.c:2293

◆ PathIsSystemFolderA()

BOOL WINAPI PathIsSystemFolderA ( LPCSTR  lpszPath,
DWORD  dwAttrib 
)

Definition at line 2247 of file path.c.

2248{
2249 TRACE("(%s,0x%08x)\n", debugstr_a(lpszPath), dwAttrib);
2250
2251 if (lpszPath && *lpszPath)
2252 dwAttrib = GetFileAttributesA(lpszPath);
2253
2254 if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY) ||
2256 return FALSE;
2257 return TRUE;
2258}
#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 2265 of file path.c.

2266{
2267 TRACE("(%s,0x%08x)\n", debugstr_w(lpszPath), dwAttrib);
2268
2269 if (lpszPath && *lpszPath)
2270 dwAttrib = GetFileAttributesW(lpszPath);
2271
2272 if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY) ||
2274 return FALSE;
2275 return TRUE;
2276}

Referenced by CViewStatePropertyBag::_IsSystemFolder().

◆ PathIsUNCA()

BOOL WINAPI PathIsUNCA ( LPCSTR  lpszPath)

Definition at line 2290 of file path.c.

2291{
2292 TRACE("(%s)\n",debugstr_a(lpszPath));
2293
2294/*
2295 * On Windows 2003, tests show that strings starting with "\\?" are
2296 * considered UNC, while on Windows Vista+ this is not the case anymore.
2297 */
2298// #ifdef __REACTOS__
2299#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
2300 if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\') && (lpszPath[2]!='?'))
2301#else
2302 if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'))
2303#endif
2304 return TRUE;
2305 return FALSE;
2306}

◆ PathIsUNCServerA()

BOOL WINAPI PathIsUNCServerA ( LPCSTR  lpszPath)

Definition at line 2348 of file path.c.

2349{
2350 TRACE("(%s)\n", debugstr_a(lpszPath));
2351
2352 if (lpszPath && *lpszPath++ == '\\' && *lpszPath++ == '\\')
2353 {
2354 while (*lpszPath)
2355 {
2356 if (*lpszPath == '\\')
2357 return FALSE;
2358 lpszPath = CharNextA(lpszPath);
2359 }
2360 return TRUE;
2361 }
2362 return FALSE;
2363}

◆ PathIsUNCServerShareA()

BOOL WINAPI PathIsUNCServerShareA ( LPCSTR  lpszPath)

Definition at line 2398 of file path.c.

2399{
2400 TRACE("(%s)\n", debugstr_a(lpszPath));
2401
2402 if (lpszPath && *lpszPath++ == '\\' && *lpszPath++ == '\\')
2403 {
2404 BOOL bSeenSlash = FALSE;
2405 while (*lpszPath)
2406 {
2407 if (*lpszPath == '\\')
2408 {
2409 if (bSeenSlash)
2410 return FALSE;
2411 bSeenSlash = TRUE;
2412 }
2413 lpszPath = CharNextA(lpszPath);
2414 }
2415 return bSeenSlash;
2416 }
2417 return FALSE;
2418}

◆ PathIsUNCServerShareW()

BOOL WINAPI PathIsUNCServerShareW ( LPCWSTR  lpszPath)

Definition at line 2425 of file path.c.

2426{
2427 TRACE("(%s)\n", debugstr_w(lpszPath));
2428
2429 if (lpszPath && *lpszPath++ == '\\' && *lpszPath++ == '\\')
2430 {
2431 BOOL bSeenSlash = FALSE;
2432 while (*lpszPath)
2433 {
2434 if (*lpszPath == '\\')
2435 {
2436 if (bSeenSlash)
2437 return FALSE;
2438 bSeenSlash = TRUE;
2439 }
2440 lpszPath++;
2441 }
2442 return bSeenSlash;
2443 }
2444 return FALSE;
2445}

◆ PathIsUNCServerW()

BOOL WINAPI PathIsUNCServerW ( LPCWSTR  lpszPath)

Definition at line 2370 of file path.c.

2371{
2372 TRACE("(%s)\n", debugstr_w(lpszPath));
2373
2374 if (lpszPath && lpszPath[0] == '\\' && lpszPath[1] == '\\')
2375 {
2376 return !strchrW( lpszPath + 2, '\\' );
2377 }
2378 return FALSE;
2379}
#define strchrW(s, c)
Definition: unicode.h:34

◆ PathIsUNCW()

BOOL WINAPI PathIsUNCW ( LPCWSTR  lpszPath)

Definition at line 2313 of file path.c.

2314{
2315 TRACE("(%s)\n",debugstr_w(lpszPath));
2316
2317/*
2318 * On Windows 2003, tests show that strings starting with "\\?" are
2319 * considered UNC, while on Windows Vista+ this is not the case anymore.
2320 */
2321// #ifdef __REACTOS__
2322#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
2323 if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\') && (lpszPath[2]!='?'))
2324#else
2325 if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'))
2326#endif
2327 return TRUE;
2328 return FALSE;
2329}

◆ PathIsValidCharA()

BOOL WINAPI PathIsValidCharA ( char  c,
DWORD  class 
)

Definition at line 4437 of file path.c.

4438{
4439 if ((unsigned)c > 0x7e)
4440 return class & PATH_CHAR_CLASS_OTHER_VALID;
4441
4442 return class & SHELL_charclass[(unsigned)c];
4443}
#define PATH_CHAR_CLASS_OTHER_VALID
Definition: path.c:2139
static const DWORD SHELL_charclass[]
Definition: path.c:4364
const GLubyte * c
Definition: glext.h:8905
static unsigned(__cdecl *hash_bstr)(bstr_t s)

◆ PathIsValidCharW()

BOOL WINAPI PathIsValidCharW ( WCHAR  c,
DWORD  class 
)

Definition at line 4450 of file path.c.

4451{
4452 if (c > 0x7e)
4453 return class & PATH_CHAR_CLASS_OTHER_VALID;
4454
4455 return class & SHELL_charclass[c];
4456}
#define c
Definition: ke_i.h:80

◆ PathMakePrettyA()

BOOL WINAPI PathMakePrettyA ( LPSTR  lpszPath)

Definition at line 2715 of file path.c.

2716{
2717 LPSTR pszIter = lpszPath;
2718
2719 TRACE("(%s)\n", debugstr_a(lpszPath));
2720
2721 if (!pszIter)
2722 return FALSE;
2723
2724 if (*pszIter)
2725 {
2726 do
2727 {
2728 if (islower(*pszIter) || IsDBCSLeadByte(*pszIter))
2729 return FALSE; /* Not DOS path */
2730 pszIter++;
2731 } while (*pszIter);
2732 pszIter = lpszPath + 1;
2733 while (*pszIter)
2734 {
2735 *pszIter = tolower(*pszIter);
2736 pszIter++;
2737 }
2738 }
2739 return TRUE;
2740}
#define islower(c)
Definition: acclib.h:72

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

◆ PathMakePrettyW()

BOOL WINAPI PathMakePrettyW ( LPWSTR  lpszPath)

Definition at line 2747 of file path.c.

2748{
2749 LPWSTR pszIter = lpszPath;
2750
2751 TRACE("(%s)\n", debugstr_w(lpszPath));
2752
2753 if (!pszIter)
2754 return FALSE;
2755
2756 if (*pszIter)
2757 {
2758 do
2759 {
2760 if (islowerW(*pszIter))
2761 return FALSE; /* Not DOS path */
2762 pszIter++;
2763 } while (*pszIter);
2764 pszIter = lpszPath + 1;
2765 while (*pszIter)
2766 {
2767 *pszIter = tolowerW(*pszIter);
2768 pszIter++;
2769 }
2770 }
2771 return TRUE;
2772}
#define islowerW(n)
Definition: unicode.h:46

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

◆ PathMakeSystemFolderA()

BOOL WINAPI PathMakeSystemFolderA ( LPCSTR  lpszPath)

Definition at line 3147 of file path.c.

3148{
3149 BOOL bRet = FALSE;
3150
3151 TRACE("(%s)\n", debugstr_a(lpszPath));
3152
3153 if (lpszPath && *lpszPath)
3154 {
3158 }
3159 return bRet;
3160}
BOOL WINAPI PathMakeSystemFolderW(LPCWSTR lpszPath)
Definition: path.c:3167

◆ PathMakeSystemFolderW()

BOOL WINAPI PathMakeSystemFolderW ( LPCWSTR  lpszPath)

Definition at line 3167 of file path.c.

3168{
3169 DWORD dwDefaultAttr = FILE_ATTRIBUTE_READONLY, dwAttr;
3171
3172 TRACE("(%s)\n", debugstr_w(lpszPath));
3173
3174 if (!lpszPath || !*lpszPath)
3175 return FALSE;
3176
3177 /* If the directory is already a system directory, don't do anything */
3179 if (!strcmpW(buff, lpszPath))
3180 return TRUE;
3181
3183 if (!strcmpW(buff, lpszPath))
3184 return TRUE;
3185
3186 /* "UseSystemForSystemFolders" Tells Win what attributes to use */
3188 dwDefaultAttr = FILE_ATTRIBUTE_SYSTEM;
3189
3190 if ((dwAttr = GetFileAttributesW(lpszPath)) == INVALID_FILE_ATTRIBUTES)
3191 return FALSE;
3192
3193 /* Change file attributes to system attributes */
3195 return SetFileAttributesW(lpszPath, dwAttr | dwDefaultAttr);
3196}
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:3117
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703

Referenced by PathMakeSystemFolderA(), and SHCreatePropertyBagOnProfileSection().

◆ PathMatchSingleMaskA()

static BOOL PathMatchSingleMaskA ( LPCSTR  name,
LPCSTR  mask 
)
static

Definition at line 1900 of file path.c.

1901{
1902 while (*name && *mask && *mask!=';')
1903 {
1904 if (*mask == '*')
1905 {
1906 do
1907 {
1909 return TRUE; /* try substrings */
1910 } while (*name++);
1911 return FALSE;
1912 }
1913
1914 if (toupper(*mask) != toupper(*name) && *mask != '?')
1915 return FALSE;
1916
1917 name = CharNextA(name);
1918 mask = CharNextA(mask);
1919 }
1920
1921 if (!*name)
1922 {
1923 while (*mask == '*')
1924 mask++;
1925 if (!*mask || *mask == ';')
1926 return TRUE;
1927 }
1928 return FALSE;
1929}
int CDECL toupper(int c)
Definition: ctype.c:514
static BOOL PathMatchSingleMaskA(LPCSTR name, LPCSTR mask)
Definition: path.c:1900
GLenum GLint GLuint mask
Definition: glext.h:6028

Referenced by PathMatchSingleMaskA(), and PathMatchSpecA().

◆ PathMatchSingleMaskW()

static BOOL PathMatchSingleMaskW ( LPCWSTR  name,
LPCWSTR  mask 
)
static

Definition at line 1934 of file path.c.

1935{
1936 while (*name && *mask && *mask != ';')
1937 {
1938 if (*mask == '*')
1939 {
1940 do
1941 {
1943 return TRUE; /* try substrings */
1944 } while (*name++);
1945 return FALSE;
1946 }
1947
1948 if (toupperW(*mask) != toupperW(*name) && *mask != '?')
1949 return FALSE;
1950
1951 name++;
1952 mask++;
1953 }
1954 if (!*name)
1955 {
1956 while (*mask == '*')
1957 mask++;
1958 if (!*mask || *mask == ';')
1959 return TRUE;
1960 }
1961 return FALSE;
1962}
static BOOL PathMatchSingleMaskW(LPCWSTR name, LPCWSTR mask)
Definition: path.c:1934
#define toupperW(n)
Definition: unicode.h:45

Referenced by PathMatchSingleMaskW(), and PathMatchSpecW().

◆ PathMatchSpecA()

BOOL WINAPI PathMatchSpecA ( LPCSTR  lpszPath,
LPCSTR  lpszMask 
)

Definition at line 1982 of file path.c.

1983{
1984 TRACE("(%s,%s)\n", lpszPath, lpszMask);
1985
1986 if (!lstrcmpA(lpszMask, "*.*"))
1987 return TRUE; /* Matches every path */
1988
1989 while (*lpszMask)
1990 {
1991 while (*lpszMask == ' ')
1992 lpszMask++; /* Eat leading spaces */
1993
1994 if (PathMatchSingleMaskA(lpszPath, lpszMask))
1995 return TRUE; /* Matches the current mask */
1996
1997 while (*lpszMask && *lpszMask != ';')
1998 lpszMask = CharNextA(lpszMask); /* masks separated by ';' */
1999
2000 if (*lpszMask == ';')
2001 lpszMask++;
2002 }
2003 return FALSE;
2004}
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4104

◆ PathMatchSpecW()

BOOL WINAPI PathMatchSpecW ( LPCWSTR  lpszPath,
LPCWSTR  lpszMask 
)

Definition at line 2011 of file path.c.

2012{
2013 static const WCHAR szStarDotStar[] = { '*', '.', '*', '\0' };
2014
2015 TRACE("(%s,%s)\n", debugstr_w(lpszPath), debugstr_w(lpszMask));
2016
2017 if (!lstrcmpW(lpszMask, szStarDotStar))
2018 return TRUE; /* Matches every path */
2019
2020 while (*lpszMask)
2021 {
2022 while (*lpszMask == ' ')
2023 lpszMask++; /* Eat leading spaces */
2024
2025 if (PathMatchSingleMaskW(lpszPath, lpszMask))
2026 return TRUE; /* Matches the current path */
2027
2028 while (*lpszMask && *lpszMask != ';')
2029 lpszMask++; /* masks separated by ';' */
2030
2031 if (*lpszMask == ';')
2032 lpszMask++;
2033 }
2034 return FALSE;
2035}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152

◆ PathParseIconLocationA()

int WINAPI PathParseIconLocationA ( LPSTR  lpszPath)

Definition at line 1076 of file path.c.

1077{
1078 int iRet = 0;
1079 LPSTR lpszComma;
1080
1081 TRACE("(%s)\n", debugstr_a(lpszPath));
1082
1083 if (lpszPath)
1084 {
1085 if ((lpszComma = strchr(lpszPath, ',')))
1086 {
1087 *lpszComma++ = '\0';
1088 iRet = StrToIntA(lpszComma);
1089 }
1090 PathUnquoteSpacesA(lpszPath);
1091 PathRemoveBlanksA(lpszPath);
1092 }
1093 return iRet;
1094}
INT WINAPI StrToIntA(LPCSTR lpszStr)
Definition: string.c:370
void WINAPI PathRemoveBlanksA(char *path)
Definition: path.c:1886
void WINAPI PathUnquoteSpacesA(char *path)
Definition: path.c:1988
_ACRTIMP char *__cdecl strchr(const char *, int)
Definition: string.c:3286

◆ PathParseIconLocationW()

int WINAPI PathParseIconLocationW ( LPWSTR  lpszPath)

Definition at line 1101 of file path.c.

1102{
1103 int iRet = 0;
1104 LPWSTR lpszComma;
1105
1106 TRACE("(%s)\n", debugstr_w(lpszPath));
1107
1108 if (lpszPath)
1109 {
1110 if ((lpszComma = StrChrW(lpszPath, ',')))
1111 {
1112 *lpszComma++ = '\0';
1113 iRet = StrToIntW(lpszComma);
1114 }
1115 PathUnquoteSpacesW(lpszPath);
1116 PathRemoveBlanksW(lpszPath);
1117 }
1118 return iRet;
1119}
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:407
void WINAPI PathRemoveBlanksW(WCHAR *path)
Definition: path.c:1910
void WINAPI PathUnquoteSpacesW(WCHAR *path)
Definition: path.c:2006

◆ PathQuoteSpacesA()

VOID WINAPI PathQuoteSpacesA ( LPSTR  lpszPath)

Definition at line 964 of file path.c.

965{
966 TRACE("(%s)\n", debugstr_a(lpszPath));
967
968 if(lpszPath && StrChrA(lpszPath,' '))
969 {
970 size_t iLen = strlen(lpszPath) + 1;
971
972 if (iLen + 2 < MAX_PATH)
973 {
974 memmove(lpszPath + 1, lpszPath, iLen);
975 lpszPath[0] = '"';
976 lpszPath[iLen] = '"';
977 lpszPath[iLen + 1] = '\0';
978 }
979 }
980}
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

◆ PathQuoteSpacesW()

VOID WINAPI PathQuoteSpacesW ( LPWSTR  lpszPath)

Definition at line 987 of file path.c.

988{
989 TRACE("(%s)\n", debugstr_w(lpszPath));
990
991 if(lpszPath && StrChrW(lpszPath,' '))
992 {
993 int iLen = strlenW(lpszPath) + 1;
994
995 if (iLen + 2 < MAX_PATH)
996 {
997 memmove(lpszPath + 1, lpszPath, iLen * sizeof(WCHAR));
998 lpszPath[0] = '"';
999 lpszPath[iLen] = '"';
1000 lpszPath[iLen + 1] = '\0';
1001 }
1002 }
1003}

◆ PathRelativePathToA()

BOOL WINAPI PathRelativePathToA ( LPSTR  lpszPath,
LPCSTR  lpszFrom,
DWORD  dwAttrFrom,
LPCSTR  lpszTo,
DWORD  dwAttrTo 
)

Definition at line 3593 of file path.c.

3595{
3596 BOOL bRet = FALSE;
3597
3598 TRACE("(%p,%s,0x%08x,%s,0x%08x)\n", lpszPath, debugstr_a(lpszFrom),
3599 dwAttrFrom, debugstr_a(lpszTo), dwAttrTo);
3600
3601 if(lpszPath && lpszFrom && lpszTo)
3602 {
3604 WCHAR szFrom[MAX_PATH];
3605 WCHAR szTo[MAX_PATH];
3606 MultiByteToWideChar(CP_ACP,0,lpszFrom,-1,szFrom,MAX_PATH);
3607 MultiByteToWideChar(CP_ACP,0,lpszTo,-1,szTo,MAX_PATH);
3608 bRet = PathRelativePathToW(szPath,szFrom,dwAttrFrom,szTo,dwAttrTo);
3609 WideCharToMultiByte(CP_ACP,0,szPath,-1,lpszPath,MAX_PATH,0,0);
3610 }
3611 return bRet;
3612}
BOOL WINAPI PathRelativePathToW(WCHAR *path, const WCHAR *from, DWORD attributes_from, const WCHAR *to, DWORD attributes_to)
Definition: path.c:2376

◆ PathRelativePathToW()

BOOL WINAPI PathRelativePathToW ( LPWSTR  lpszPath,
LPCWSTR  lpszFrom,
DWORD  dwAttrFrom,
LPCWSTR  lpszTo,
DWORD  dwAttrTo 
)

Definition at line 3619 of file path.c.

3621{
3622 static const WCHAR szPrevDirSlash[] = { '.', '.', '\\', '\0' };
3623 static const WCHAR szPrevDir[] = { '.', '.', '\0' };
3624 WCHAR szFrom[MAX_PATH];
3625 WCHAR szTo[MAX_PATH];
3626 DWORD dwLen;
3627
3628 TRACE("(%p,%s,0x%08x,%s,0x%08x)\n", lpszPath, debugstr_w(lpszFrom),
3629 dwAttrFrom, debugstr_w(lpszTo), dwAttrTo);
3630
3631 if(!lpszPath || !lpszFrom || !lpszTo)
3632 return FALSE;
3633
3634 *lpszPath = '\0';
3635 lstrcpynW(szFrom, lpszFrom, MAX_PATH);
3636 lstrcpynW(szTo, lpszTo, MAX_PATH);
3637
3638 if(!(dwAttrFrom & FILE_ATTRIBUTE_DIRECTORY))
3639 PathRemoveFileSpecW(szFrom);
3640 if(!(dwAttrTo & FILE_ATTRIBUTE_DIRECTORY))
3641 PathRemoveFileSpecW(szTo);
3642
3643 /* Paths can only be relative if they have a common root */
3644 if(!(dwLen = PathCommonPrefixW(szFrom, szTo, 0)))
3645 return FALSE;
3646
3647 /* Strip off lpszFrom components to the root, by adding "..\" */
3648 lpszFrom = szFrom + dwLen;
3649 if (!*lpszFrom)
3650 {
3651 lpszPath[0] = '.';
3652 lpszPath[1] = '\0';
3653 }
3654 if (*lpszFrom == '\\')
3655 lpszFrom++;
3656
3657 while (*lpszFrom)
3658 {
3659 lpszFrom = PathFindNextComponentW(lpszFrom);
3660 strcatW(lpszPath, *lpszFrom ? szPrevDirSlash : szPrevDir);
3661 }
3662
3663 /* From the root add the components of lpszTo */
3664 lpszTo += dwLen;
3665 /* We check lpszTo[-1] to avoid skipping end of string. See the notes for
3666 * this function.
3667 */
3668 if (*lpszTo && lpszTo[-1])
3669 {
3670 if (*lpszTo != '\\')
3671 lpszTo--;
3672 dwLen = strlenW(lpszPath);
3673 if (dwLen + strlenW(lpszTo) >= MAX_PATH)
3674 {
3675 *lpszPath = '\0';
3676 return FALSE;
3677 }
3678 strcpyW(lpszPath + dwLen, lpszTo);
3679 }
3680 return TRUE;
3681}
BOOL WINAPI PathRemoveFileSpecW(WCHAR *path)
Definition: path.c:1145
WCHAR *WINAPI PathFindNextComponentW(const WCHAR *path)
Definition: path.c:2248

◆ PathRemoveArgsA()

void WINAPI PathRemoveArgsA ( LPSTR  lpszPath)

Definition at line 759 of file path.c.

760{
761 TRACE("(%s)\n",debugstr_a(lpszPath));
762
763 if(lpszPath)
764 {
765 LPSTR lpszArgs = PathGetArgsA(lpszPath);
766 if (*lpszArgs)
767 lpszArgs[-1] = '\0';
768 else
769 {
770 LPSTR lpszLastChar = CharPrevA(lpszPath, lpszArgs);
771 if(*lpszLastChar == ' ')
772 *lpszLastChar = '\0';
773 }
774 }
775}
LPSTR WINAPI CharPrevA(const char *start, const char *ptr)
Definition: string.c:1128
LPSTR WINAPI PathGetArgsA(LPCSTR lpszPath)
Definition: path.c:484

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

◆ PathRemoveArgsW()

void WINAPI PathRemoveArgsW ( LPWSTR  lpszPath)

Definition at line 782 of file path.c.

783{
784 TRACE("(%s)\n",debugstr_w(lpszPath));
785
786 if(lpszPath)
787 {
788 LPWSTR lpszArgs = PathGetArgsW(lpszPath);
789 if (*lpszArgs || (lpszArgs > lpszPath && lpszArgs[-1] == ' '))
790 lpszArgs[-1] = '\0';
791 }
792}
LPWSTR WINAPI PathGetArgsW(LPCWSTR lpszPath)
Definition: path.c:509

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

◆ PathRemoveBackslashA()

LPSTR WINAPI PathRemoveBackslashA ( LPSTR  lpszPath)

Definition at line 850 of file path.c.

851{
852 LPSTR szTemp = NULL;
853
854 TRACE("(%s)\n", debugstr_a(lpszPath));
855
856 if(lpszPath)
857 {
858 szTemp = CharPrevA(lpszPath, lpszPath + strlen(lpszPath));
859 if (!PathIsRootA(lpszPath) && *szTemp == '\\')
860 *szTemp = '\0';
861 }
862 return szTemp;
863}
BOOL WINAPI PathIsRootA(const char *path)
Definition: path.c:1088

◆ PathRemoveBackslashW()

LPWSTR WINAPI PathRemoveBackslashW ( LPWSTR  lpszPath)

Definition at line 870 of file path.c.

871{
872 LPWSTR szTemp = NULL;
873
874 TRACE("(%s)\n", debugstr_w(lpszPath));
875
876 if(lpszPath)
877 {
878 szTemp = lpszPath + strlenW(lpszPath);
879 if (szTemp > lpszPath) szTemp--;
880 if (!PathIsRootW(lpszPath) && *szTemp == '\\')
881 *szTemp = '\0';
882 }
883 return szTemp;
884}
BOOL WINAPI PathIsRootW(const WCHAR *path)
Definition: path.c:1101

◆ PathRemoveBlanksA()

void WINAPI PathRemoveBlanksA ( LPSTR  pszPath)

Definition at line 897 of file path.c.

898{
900
901 TRACE("(%s)\n", debugstr_a(pszPath));
902
903 if (!pszPath || !*pszPath)
904 return;
905
906 start = first = pszPath;
907
908 while (*pszPath == ' ')
909 pszPath = CharNextA(pszPath);
910
911 while (*pszPath)
912 *start++ = *pszPath++;
913
914 if (start != first)
915 while (start[-1] == ' ')
916 start--;
917
918 *start = '\0';
919}
GLuint start
Definition: gl.h:1545
const GLint * first
Definition: glext.h:5794

◆ PathRemoveBlanksW()

void WINAPI PathRemoveBlanksW ( LPWSTR  pszPath)

Definition at line 926 of file path.c.

927{
929
930 TRACE("(%s)\n", debugstr_w(pszPath));
931
932 if (!pszPath || !*pszPath)
933 return;
934
935 start = first = pszPath;
936
937 while (*pszPath == ' ')
938 pszPath++;
939
940 while (*pszPath)
941 *start++ = *pszPath++;
942
943 if (start != first)
944 while (start[-1] == ' ')
945 start--;
946
947 *start = '\0';
948}

◆ PathRemoveExtensionA()

void WINAPI PathRemoveExtensionA ( LPSTR  lpszPath)

Definition at line 809 of file path.c.

810{
811 TRACE("(%s)\n", debugstr_a(lpszPath));
812
813 if (lpszPath)
814 {
815 lpszPath = PathFindExtensionA(lpszPath);
816 if (lpszPath && *lpszPath != '\0')
817 *lpszPath = '\0';
818 }
819}

◆ PathRemoveExtensionW()

void WINAPI PathRemoveExtensionW ( LPWSTR  lpszPath)

Definition at line 826 of file path.c.

827{
828 TRACE("(%s)\n", debugstr_w(lpszPath));
829
830 if (lpszPath)
831 {
832 lpszPath = PathFindExtensionW(lpszPath);
833 if (lpszPath && *lpszPath != '\0')
834 *lpszPath = '\0';
835 }
836}

◆ PathRemoveFileSpecA()

BOOL WINAPI PathRemoveFileSpecA ( LPSTR  lpszPath)

Definition at line 589 of file path.c.

590{
591 LPSTR lpszFileSpec = lpszPath;
592 BOOL bModified = FALSE;
593
594 TRACE("(%s)\n",debugstr_a(lpszPath));
595
596 if(lpszPath)
597 {
598 /* Skip directory or UNC path */
599 if (*lpszPath == '\\')
600 lpszFileSpec = ++lpszPath;
601 if (*lpszPath == '\\')
602 lpszFileSpec = ++lpszPath;
603
604 while (*lpszPath)
605 {
606 if(*lpszPath == '\\')
607 lpszFileSpec = lpszPath; /* Skip dir */
608 else if(*lpszPath == ':')
609 {
610 lpszFileSpec = ++lpszPath; /* Skip drive */
611 if (*lpszPath == '\\')
612 lpszFileSpec++;
613 }
614 if (!(lpszPath = CharNextA(lpszPath)))
615 break;
616 }
617
618 if (*lpszFileSpec)
619 {
620 *lpszFileSpec = '\0';
621 bModified = TRUE;
622 }
623 }
624 return bModified;
625}

◆ PathRemoveFileSpecW()

BOOL WINAPI PathRemoveFileSpecW ( LPWSTR  lpszPath)

Definition at line 632 of file path.c.

633{
634 LPWSTR lpszFileSpec = lpszPath;
635 BOOL bModified = FALSE;
636
637 TRACE("(%s)\n",debugstr_w(lpszPath));
638
639 if(lpszPath)
640 {
641 /* Skip directory or UNC path */
642 if (*lpszPath == '\\')
643 lpszFileSpec = ++lpszPath;
644 if (*lpszPath == '\\')
645 lpszFileSpec = ++lpszPath;
646
647 while (*lpszPath)
648 {
649 if(*lpszPath == '\\')
650 lpszFileSpec = lpszPath; /* Skip dir */
651 else if(*lpszPath == ':')
652 {
653 lpszFileSpec = ++lpszPath; /* Skip drive */
654 if (*lpszPath == '\\')
655 lpszFileSpec++;
656 }
657 lpszPath++;
658 }
659
660 if (*lpszFileSpec)
661 {
662 *lpszFileSpec = '\0';
663 bModified = TRUE;
664 }
665 }
666 return bModified;
667}

◆ PathRenameExtensionA()

BOOL WINAPI PathRenameExtensionA ( LPSTR  lpszPath,
LPCSTR  lpszExt 
)

Definition at line 3211 of file path.c.

3212{
3213 LPSTR lpszExtension;
3214
3215 TRACE("(%s,%s)\n", debugstr_a(lpszPath), debugstr_a(lpszExt));
3216
3217 lpszExtension = PathFindExtensionA(lpszPath);
3218
3219 if (!lpszExtension || (lpszExtension - lpszPath + strlen(lpszExt) >= MAX_PATH))
3220 return FALSE;
3221
3222 strcpy(lpszExtension, lpszExt);
3223 return TRUE;
3224}

◆ PathRenameExtensionW()

BOOL WINAPI PathRenameExtensionW ( LPWSTR  lpszPath,
LPCWSTR  lpszExt 
)

Definition at line 3231 of file path.c.

3232{
3233 LPWSTR lpszExtension;
3234
3235 TRACE("(%s,%s)\n", debugstr_w(lpszPath), debugstr_w(lpszExt));
3236
3237 lpszExtension = PathFindExtensionW(lpszPath);
3238
3239 if (!lpszExtension || (lpszExtension - lpszPath + strlenW(lpszExt) >= MAX_PATH))
3240 return FALSE;
3241
3242 strcpyW(lpszExtension, lpszExt);
3243 return TRUE;
3244}

◆ PathSearchAndQualifyA()

BOOL WINAPI PathSearchAndQualifyA ( LPCSTR  lpszPath,
LPSTR  lpszBuf,
UINT  cchBuf 
)

Definition at line 3259 of file path.c.

3260{
3261 TRACE("(%s,%p,0x%08x)\n", debugstr_a(lpszPath), lpszBuf, cchBuf);
3262
3263 if(SearchPathA(NULL, lpszPath, NULL, cchBuf, lpszBuf, NULL))
3264 return TRUE;
3265 return !!GetFullPathNameA(lpszPath, cchBuf, lpszBuf, NULL);
3266}
DWORD WINAPI SearchPathA(IN LPCSTR lpPath OPTIONAL, IN LPCSTR lpFileName, IN LPCSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPSTR lpBuffer, OUT LPSTR *lpFilePart OPTIONAL)
Definition: path.c:1123
DWORD WINAPI GetFullPathNameA(IN LPCSTR lpFileName, IN DWORD nBufferLength, OUT LPSTR lpBuffer, OUT LPSTR *lpFilePart)
Definition: path.c:993
_In_ UINT cchBuf
Definition: shlwapi.h:378

◆ PathSearchAndQualifyW()

BOOL WINAPI PathSearchAndQualifyW ( LPCWSTR  lpszPath,
LPWSTR  lpszBuf,
UINT  cchBuf 
)

Definition at line 3273 of file path.c.

3274{
3275 TRACE("(%s,%p,0x%08x)\n", debugstr_w(lpszPath), lpszBuf, cchBuf);
3276
3277 if(SearchPathW(NULL, lpszPath, NULL, cchBuf, lpszBuf, NULL))
3278 return TRUE;
3279 return !!GetFullPathNameW(lpszPath, cchBuf, lpszBuf, NULL);
3280}
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1298
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106

◆ PathSetDlgItemPathA()

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

Definition at line 3748 of file path.c.

3749{
3751
3752 TRACE("(%p,%8x,%s)\n",hDlg, id, debugstr_a(lpszPath));
3753
3754 if (lpszPath)
3756 else
3757 szPath[0] = '\0';
3758 PathSetDlgItemPathW(hDlg, id, szPath);
3759}
VOID WINAPI PathSetDlgItemPathW(HWND hDlg, int id, LPCWSTR lpszPath)
Definition: path.c:3766

◆ PathSetDlgItemPathW()

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

Definition at line 3766 of file path.c.

3767{
3768 WCHAR path[MAX_PATH + 1];
3769 HWND hwItem;
3770 RECT rect;
3771 HDC hdc;
3772 HGDIOBJ hPrevObj;
3773
3774 TRACE("(%p,%8x,%s)\n",hDlg, id, debugstr_w(lpszPath));
3775
3776 if (!(hwItem = GetDlgItem(hDlg, id)))
3777 return;
3778
3779 if (lpszPath)
3780 lstrcpynW(path, lpszPath, sizeof(path) / sizeof(WCHAR));
3781 else
3782 path[0] = '\0';
3783
3784 GetClientRect(hwItem, &rect);
3785 hdc = GetDC(hDlg);
3786 hPrevObj = SelectObject(hdc, (HGDIOBJ)SendMessageW(hwItem,WM_GETFONT,0,0));
3787
3788 if (hPrevObj)
3789 {
3791 SelectObject(hdc, hPrevObj);
3792 }
3793
3794 ReleaseDC(hDlg, hdc);
3795 SetWindowTextW(hwItem, path);
3796}
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().

◆ PathSkipRootA()

LPSTR WINAPI PathSkipRootA ( LPCSTR  lpszPath)

Definition at line 3294 of file path.c.

3295{
3296 TRACE("(%s)\n", debugstr_a(lpszPath));
3297
3298 if (!lpszPath || !*lpszPath)
3299 return NULL;
3300
3301 if (*lpszPath == '\\' && lpszPath[1] == '\\')
3302 {
3303 /* Network share: skip share server and mount point */
3304 lpszPath += 2;
3305 if ((lpszPath = StrChrA(lpszPath, '\\')) &&
3306 (lpszPath = StrChrA(lpszPath + 1, '\\')))
3307 lpszPath++;
3308 return (LPSTR)lpszPath;
3309 }
3310
3311 if (IsDBCSLeadByte(*lpszPath))
3312 return NULL;
3313
3314 /* Check x:\ */
3315 if (lpszPath[0] && lpszPath[1] == ':' && lpszPath[2] == '\\')
3316 return (LPSTR)lpszPath + 3;
3317 return NULL;
3318}

◆ PathSkipRootW()

LPWSTR WINAPI PathSkipRootW ( LPCWSTR  lpszPath)

Definition at line 3325 of file path.c.

3326{
3327 TRACE("(%s)\n", debugstr_w(lpszPath));
3328
3329 if (!lpszPath || !*lpszPath)
3330 return NULL;
3331
3332 if (*lpszPath == '\\' && lpszPath[1] == '\\')
3333 {
3334 /* Network share: skip share server and mount point */
3335 lpszPath += 2;
3336 if ((lpszPath = StrChrW(lpszPath, '\\')) &&
3337 (lpszPath = StrChrW(lpszPath + 1, '\\')))
3338 lpszPath++;
3339 return (LPWSTR)lpszPath;
3340 }
3341
3342 /* Check x:\ */
3343 if (lpszPath[0] && lpszPath[1] == ':' && lpszPath[2] == '\\')
3344 return (LPWSTR)lpszPath + 3;
3345 return NULL;
3346}

◆ PathStripPathA()

void WINAPI PathStripPathA ( LPSTR  lpszPath)

Definition at line 680 of file path.c.

681{
682 TRACE("(%s)\n", debugstr_a(lpszPath));
683
684 if (lpszPath)
685 {
686 LPSTR lpszFileName = PathFindFileNameA(lpszPath);
687 if(lpszFileName != lpszPath)
688 RtlMoveMemory(lpszPath, lpszFileName, strlen(lpszFileName)+1);
689 }
690}
char *WINAPI PathFindFileNameA(const char *path)
Definition: path.c:1684
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

◆ PathStripPathW()

void WINAPI PathStripPathW ( LPWSTR  lpszPath)

Definition at line 697 of file path.c.

698{
699 LPWSTR lpszFileName;
700
701 TRACE("(%s)\n", debugstr_w(lpszPath));
702 lpszFileName = PathFindFileNameW(lpszPath);
703 if(lpszFileName != lpszPath)
704 RtlMoveMemory(lpszPath, lpszFileName, (strlenW(lpszFileName)+1)*sizeof(WCHAR));
705}

◆ PathStripToRootA()

BOOL WINAPI PathStripToRootA ( LPSTR  lpszPath)

Definition at line 719 of file path.c.

720{
721 TRACE("(%s)\n", debugstr_a(lpszPath));
722
723 if (!lpszPath)
724 return FALSE;
725 while(!PathIsRootA(lpszPath))
726 if (!PathRemoveFileSpecA(lpszPath))
727 return FALSE;
728 return TRUE;
729}
BOOL WINAPI PathRemoveFileSpecA(LPSTR lpszPath)
Definition: path.c:589

◆ PathStripToRootW()

BOOL WINAPI PathStripToRootW ( LPWSTR  lpszPath)

Definition at line 736 of file path.c.

737{
738 TRACE("(%s)\n", debugstr_w(lpszPath));
739
740 if (!lpszPath)
741 return FALSE;
742 while(!PathIsRootW(lpszPath))
743 if (!PathRemoveFileSpecW(lpszPath))
744 return FALSE;
745 return TRUE;
746}

◆ PathUndecorateA()

void WINAPI PathUndecorateA ( LPSTR  pszPath)

Definition at line 4111 of file path.c.

4112{
4113 char *ext, *skip;
4114
4115 TRACE("(%s)\n", debugstr_a(pszPath));
4116
4117 if (!pszPath) return;
4118
4119 ext = PathFindExtensionA(pszPath);
4120 if (ext == pszPath || ext[-1] != ']') return;
4121
4122 skip = ext - 2;
4123 while (skip > pszPath && '0' <= *skip && *skip <= '9')
4124 skip--;
4125
4126 if (skip > pszPath && *skip == '[' && skip[-1] != '\\')
4127 memmove(skip, ext, strlen(ext) + 1);
4128}
#define skip(...)
Definition: atltest.h:64
static const WCHAR *const ext[]
Definition: module.c:53

Referenced by test_PathUndecorate().

◆ PathUndecorateW()

void WINAPI PathUndecorateW ( LPWSTR  pszPath)

Definition at line 4135 of file path.c.

4136{
4137 WCHAR *ext, *skip;
4138
4139 TRACE("(%s)\n", debugstr_w(pszPath));
4140
4141 if (!pszPath) return;
4142
4143 ext = PathFindExtensionW(pszPath);
4144 if (ext == pszPath || ext[-1] != ']') return;
4145
4146 skip = ext - 2;
4147 while (skip > pszPath && '0' <= *skip && *skip <= '9')
4148 skip--;
4149
4150 if (skip > pszPath && *skip == '[' && skip[-1] != '\\')
4151 memmove(skip, ext, (wcslen(ext) + 1) * sizeof(WCHAR));
4152}
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983

Referenced by test_PathUndecorate().

◆ PathUnExpandEnvStringsA()

BOOL WINAPI PathUnExpandEnvStringsA ( LPCSTR  path,
LPSTR  buffer,
UINT  buf_len 
)

Definition at line 4169 of file path.c.

4170{
4171 WCHAR bufferW[MAX_PATH], *pathW;
4172 DWORD len;
4173 BOOL ret;
4174
4175 TRACE("(%s, %p, %d)\n", debugstr_a(path), buffer, buf_len);
4176
4178 if (!pathW) return FALSE;
4179
4182 if (!ret) return FALSE;
4183
4184 len = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
4185 if (buf_len < len + 1) return FALSE;
4186
4187 WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, buf_len, NULL, NULL);
4188 return TRUE;
4189}
static WCHAR * heap_strdupAtoW(const char *str)
Definition: path.c:131
BOOL WINAPI PathUnExpandEnvStringsW(const WCHAR *path, WCHAR *buffer, UINT buf_len)
Definition: path.c:2705

◆ PathUnExpandEnvStringsW()

BOOL WINAPI PathUnExpandEnvStringsW ( LPCWSTR  path,
LPWSTR  buffer,
UINT  buf_len 
)

Definition at line 4222 of file path.c.

4223{
4224 static struct envvars_map null_var = {NULL, 0, {0}, 0};
4225 struct envvars_map *match = &null_var, *cur;
4226 struct envvars_map envvars[] = {
4227 { allusersprofileW, sizeof(allusersprofileW)/sizeof(WCHAR) },
4228 { appdataW, sizeof(appdataW)/sizeof(WCHAR) },
4229 { programfilesW, sizeof(programfilesW)/sizeof(WCHAR) },
4230 { systemrootW, sizeof(systemrootW)/sizeof(WCHAR) },
4231 { systemdriveW, sizeof(systemdriveW)/sizeof(WCHAR) },
4232 { userprofileW, sizeof(userprofileW)/sizeof(WCHAR) },
4233 { NULL }
4234 };
4235 DWORD pathlen;
4236 UINT needed;
4237
4238 TRACE("(%s, %p, %d)\n", debugstr_w(path), buffer, buf_len);
4239
4240 pathlen = strlenW(path);
4241 init_envvars_map(envvars);
4242 cur = envvars;
4243 while (cur->var)
4244 {
4245 /* path can't contain expanded value or value wasn't retrieved */
4246 if (cur->len == 0 || cur->len > pathlen || strncmpiW(cur->path, path, cur->len))
4247 {
4248 cur++;
4249 continue;
4250 }
4251
4252 if (cur->len > match->len)
4253 match = cur;
4254 cur++;
4255 }
4256
4257 /* 'varlen' includes NULL termination char */
4258 needed = match->varlen + pathlen - match->len;
4259 if (match->len == 0 || needed > buf_len) return FALSE;
4260
4261 strcpyW(buffer, match->var);
4262 strcatW(buffer, &path[match->len]);
4263 TRACE("ret %s\n", debugstr_w(buffer));
4264
4265 return TRUE;
4266}
static void init_envvars_map(struct envvars_map *map)
Definition: path.c:2694
static const WCHAR userprofileW[]
Definition: path.c:4196
static const WCHAR systemdriveW[]
Definition: path.c:4195
static const WCHAR programfilesW[]
Definition: path.c:4193
static const WCHAR allusersprofileW[]
Definition: path.c:4191
static const WCHAR appdataW[]
Definition: path.c:4192
static const WCHAR systemrootW[]
Definition: path.c:4194
FxCollectionEntry * cur
Definition: match.c:28
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40

◆ PathUnmakeSystemFolderA()

BOOL WINAPI PathUnmakeSystemFolderA ( LPCSTR  lpszPath)

Definition at line 3696 of file path.c.

3697{
3698 DWORD dwAttr;
3699
3700 TRACE("(%s)\n", debugstr_a(lpszPath));
3701
3702 if (!lpszPath || !*lpszPath || (dwAttr = GetFileAttributesA(lpszPath)) == INVALID_FILE_ATTRIBUTES ||
3703 !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
3704 return FALSE;
3705
3707 return SetFileAttributesA(lpszPath, dwAttr);
3708}
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:760

◆ PathUnmakeSystemFolderW()

BOOL WINAPI PathUnmakeSystemFolderW ( LPCWSTR  lpszPath)

Definition at line 3715 of file path.c.

3716{
3717 DWORD dwAttr;
3718
3719 TRACE("(%s)\n", debugstr_w(lpszPath));
3720
3721 if (!lpszPath || !*lpszPath || (dwAttr = GetFileAttributesW(lpszPath)) == INVALID_FILE_ATTRIBUTES ||
3722 !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
3723 return FALSE;
3724
3726 return SetFileAttributesW(lpszPath, dwAttr);
3727}

◆ PathUnquoteSpacesA()

VOID WINAPI PathUnquoteSpacesA ( LPSTR  lpszPath)

Definition at line 1021 of file path.c.

1022{
1023 TRACE("(%s)\n", debugstr_a(lpszPath));
1024
1025 if (lpszPath && *lpszPath == '"')
1026 {
1027 DWORD dwLen = strlen(lpszPath) - 1;
1028
1029 if (lpszPath[dwLen] == '"')
1030 {
1031 lpszPath[dwLen] = '\0';
1032 for (; *lpszPath; lpszPath++)
1033 *lpszPath = lpszPath[1];
1034 }
1035 }
1036}

◆ PathUnquoteSpacesW()

VOID WINAPI PathUnquoteSpacesW ( LPWSTR  lpszPath)

Definition at line 1043 of file path.c.

1044{
1045 TRACE("(%s)\n", debugstr_w(lpszPath));
1046
1047 if (lpszPath && *lpszPath == '"')
1048 {
1049 DWORD dwLen = strlenW(lpszPath) - 1;
1050
1051 if (lpszPath[dwLen] == '"')
1052 {
1053 lpszPath[dwLen] = '\0';
1054 for (; *lpszPath; lpszPath++)
1055 *lpszPath = lpszPath[1];
1056 }
1057 }
1058}

◆ SHGetWebFolderFilePathA()

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

Definition at line 4282 of file path.c.

4283{
4284 WCHAR szFile[MAX_PATH], szPath[MAX_PATH];
4285 HRESULT hRet;
4286
4287 TRACE("(%s,%p,%d)\n", lpszFile, lpszPath, dwPathLen);
4288
4289 MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, szFile, MAX_PATH);
4290 szPath[0] = '\0';
4291 hRet = SHGetWebFolderFilePathW(szFile, szPath, dwPathLen);
4292 WideCharToMultiByte(CP_ACP, 0, szPath, -1, lpszPath, dwPathLen, 0, 0);
4293 return hRet;
4294}
HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR, LPWSTR, DWORD)
Definition: path.c:4301

◆ SHGetWebFolderFilePathW()

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

Definition at line 4301 of file path.c.

4302{
4303 static const WCHAR szWeb[] = {'\\','W','e','b','\\','\0'};
4304 static const WCHAR szWebMui[] = {'m','u','i','\\','%','0','4','x','\\','\0'};
4305#define szWebLen (sizeof(szWeb)/sizeof(WCHAR))
4306#define szWebMuiLen ((sizeof(szWebMui)+1)/sizeof(WCHAR))
4307 DWORD dwLen, dwFileLen;
4308 LANGID lidSystem, lidUser;
4309
4310 TRACE("(%s,%p,%d)\n", debugstr_w(lpszFile), lpszPath, dwPathLen);
4311
4312 /* Get base directory for web content */
4313 dwLen = GetSystemWindowsDirectoryW(lpszPath, dwPathLen);
4314 if (dwLen > 0 && lpszPath[dwLen-1] == '\\')
4315 dwLen--;
4316
4317 dwFileLen = strlenW(lpszFile);
4318
4319 if (dwLen + dwFileLen + szWebLen >= dwPathLen)
4320 return E_FAIL; /* lpszPath too short */
4321
4322 strcpyW(lpszPath+dwLen, szWeb);
4323 dwLen += szWebLen;
4324 dwPathLen = dwPathLen - dwLen; /* Remaining space */
4325
4326 lidSystem = GetSystemDefaultUILanguage();
4327 lidUser = GetUserDefaultUILanguage();
4328
4329 if (lidSystem != lidUser)
4330 {
4331 if (dwFileLen + szWebMuiLen < dwPathLen)
4332 {
4333 /* Use localised content in the users UI language if present */
4334 wsprintfW(lpszPath + dwLen, szWebMui, lidUser);
4335 strcpyW(lpszPath + dwLen + szWebMuiLen, lpszFile);
4336 if (PathFileExistsW(lpszPath))
4337 return S_OK;
4338 }
4339 }
4340
4341 /* Fall back to OS default installed content */
4342 strcpyW(lpszPath + dwLen, lpszFile);
4343 if (PathFileExistsW(lpszPath))
4344 return S_OK;
4345 return E_FAIL;
4346}
#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 szWebMuiLen
#define szWebLen
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 1226 of file path.c.

1227{
1228 static const WCHAR szSystem[] = { 'S','y','s','t','e','m','\0'};
1229 static const WCHAR szPath[] = { 'P','A','T','H','\0'};
1230 DWORD dwLenPATH;
1231 LPCWSTR lpszCurr;
1232 WCHAR *lpszPATH;
1234
1235 TRACE("(%s,%08x)\n", debugstr_w(lpszFile), dwWhich);
1236
1237 /* Try system directories */
1239 if (!PathAppendW(buff, lpszFile))
1240 return FALSE;
1241 if (PathFileExistsDefExtW(buff, dwWhich))
1242 {
1243 strcpyW(lpszFile, buff);
1244 return TRUE;
1245 }
1247 if (!PathAppendW(buff, szSystem ) || !PathAppendW(buff, lpszFile))
1248 return FALSE;
1249 if (PathFileExistsDefExtW(buff, dwWhich))
1250 {
1251 strcpyW(lpszFile, buff);
1252 return TRUE;
1253 }
1255 if (!PathAppendW(buff, lpszFile))
1256 return FALSE;
1257 if (PathFileExistsDefExtW(buff, dwWhich))
1258 {
1259 strcpyW(lpszFile, buff);
1260 return TRUE;
1261 }
1262 /* Try dirs listed in %PATH% */
1264
1265 if (!dwLenPATH || !(lpszPATH = HeapAlloc(GetProcessHeap(), 0, (dwLenPATH + 1) * sizeof (WCHAR))))
1266 return FALSE;
1267
1268 GetEnvironmentVariableW(szPath, lpszPATH, dwLenPATH + 1);
1269 lpszCurr = lpszPATH;
1270 while (lpszCurr)
1271 {
1272 LPCWSTR lpszEnd = lpszCurr;
1273 LPWSTR pBuff = buff;
1274
1275 while (*lpszEnd == ' ')
1276 lpszEnd++;
1277 while (*lpszEnd && *lpszEnd != ';')
1278 *pBuff++ = *lpszEnd++;
1279 *pBuff = '\0';
1280
1281 if (*lpszEnd)
1282 lpszCurr = lpszEnd + 1;
1283 else
1284 lpszCurr = NULL; /* Last Path, terminate after this */
1285
1286 if (!PathAppendW(buff, lpszFile))
1287 {
1288 HeapFree(GetProcessHeap(), 0, lpszPATH);
1289 return FALSE;
1290 }
1291 if (PathFileExistsDefExtW(buff, dwWhich))
1292 {
1293 strcpyW(lpszFile, buff);
1294 HeapFree(GetProcessHeap(), 0, lpszPATH);
1295 return TRUE;
1296 }
1297 }
1298 HeapFree(GetProcessHeap(), 0, lpszPATH);
1299 return FALSE;
1300}
#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 3117 of file path.c.

3118{
3119 static BOOL bCheckedReg = FALSE;
3120 static BOOL bUseSystemForSystemFolders = FALSE;
3121
3122 if (!bCheckedReg)
3123 {
3124 bCheckedReg = TRUE;
3125
3126 /* Key tells Win what file attributes to use on system folders */
3128 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
3129 "UseSystemForSystemFolders", 0, 0, 0))
3130 bUseSystemForSystemFolders = TRUE;
3131 }
3132 return bUseSystemForSystemFolders;
3133}
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by PathMakeSystemFolderW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ allusersprofileW

const WCHAR allusersprofileW[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%',0}
static

Definition at line 4191 of file path.c.

Referenced by PathUnExpandEnvStringsW().

◆ appdataW

const WCHAR appdataW[] = {'%','A','P','P','D','A','T','A','%',0}
static

Definition at line 4192 of file path.c.

Referenced by PathUnExpandEnvStringsW().

◆ pIsNetDrive

fnpIsNetDrive pIsNetDrive
static

Definition at line 69 of file path.c.

Referenced by PathIsNetworkPathA(), and PathIsNetworkPathW().

◆ programfilesW

const WCHAR programfilesW[] = {'%','P','r','o','g','r','a','m','F','i','l','e','s','%',0}
static

Definition at line 4193 of file path.c.

Referenced by PathUnExpandEnvStringsW(), and test_StdRegProv().

◆ SHELL_charclass

const DWORD SHELL_charclass[]
static

◆ SHLWAPI_hshell32

HMODULE SHLWAPI_hshell32
static

Definition at line 65 of file path.c.

◆ systemdriveW

const WCHAR systemdriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%',0}
static

Definition at line 4195 of file path.c.

Referenced by PathUnExpandEnvStringsW(), and test_Win32_OperatingSystem().

◆ systemrootW

const WCHAR systemrootW[] = {'%','S','y','s','t','e','m','R','o','o','t','%',0}
static

Definition at line 4194 of file path.c.

Referenced by create_file_test(), and PathUnExpandEnvStringsW().

◆ userprofileW

const WCHAR userprofileW[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%',0}
static

Definition at line 4196 of file path.c.

Referenced by PathUnExpandEnvStringsW().