ReactOS  0.4.13-dev-257-gfabbd7c
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 lpszPath)
 
VOID WINAPI PathRemoveBlanksW (LPWSTR lpszPath)
 
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 lpszPath)
 
VOID WINAPI PathUndecorateW (LPWSTR lpszPath)
 
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)
GLenum func
Definition: glext.h:6028
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
Definition: name.c:36
#define GetProcAddress(x, y)
Definition: compat.h:410

Definition at line 47 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 4308 of file path.c.

◆ PATH_CHAR_CLASS_ASTERIX

#define PATH_CHAR_CLASS_ASTERIX   0x00000002

Definition at line 4297 of file path.c.

◆ PATH_CHAR_CLASS_BACKSLASH

#define PATH_CHAR_CLASS_BACKSLASH   0x00000008

Definition at line 4299 of file path.c.

◆ PATH_CHAR_CLASS_COLON

#define PATH_CHAR_CLASS_COLON   0x00000010

Definition at line 4300 of file path.c.

◆ PATH_CHAR_CLASS_COMMA

#define PATH_CHAR_CLASS_COMMA   0x00000040

Definition at line 4302 of file path.c.

◆ PATH_CHAR_CLASS_DOT

#define PATH_CHAR_CLASS_DOT   0x00000004

Definition at line 4298 of file path.c.

◆ PATH_CHAR_CLASS_DOUBLEQUOTE

#define PATH_CHAR_CLASS_DOUBLEQUOTE   0x00000200

Definition at line 4305 of file path.c.

◆ PATH_CHAR_CLASS_INVALID

#define PATH_CHAR_CLASS_INVALID   0x00000000

Definition at line 4307 of file path.c.

◆ PATH_CHAR_CLASS_LETTER

#define PATH_CHAR_CLASS_LETTER   0x00000001

Definition at line 4296 of file path.c.

◆ PATH_CHAR_CLASS_OTHER_VALID

#define PATH_CHAR_CLASS_OTHER_VALID   0x00000100

Definition at line 4304 of file path.c.

◆ PATH_CHAR_CLASS_SEMICOLON

#define PATH_CHAR_CLASS_SEMICOLON   0x00000020

Definition at line 4301 of file path.c.

◆ PATH_CHAR_CLASS_SPACE

#define PATH_CHAR_CLASS_SPACE   0x00000080

Definition at line 4303 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 60 of file path.c.

Function Documentation

◆ heap_strdupAtoW()

static WCHAR* heap_strdupAtoW ( LPCSTR  str)
inlinestatic

Definition at line 68 of file path.c.

69 {
70  WCHAR *ret = NULL;
71 
72  if (str)
73  {
74  DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
75  ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
76  if (ret)
78  }
79 
80  return ret;
81 }
#define CP_ACP
Definition: compat.h:99
DWORD ret
Definition: path.c:47
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100

Referenced by PathUnExpandEnvStringsA().

◆ init_envvars_map()

static void init_envvars_map ( struct envvars_map map)
static

Definition at line 4154 of file path.c.

4155 {
4156  while (map->var)
4157  {
4158  map->len = ExpandEnvironmentStringsW(map->var, map->path, sizeof(map->path)/sizeof(WCHAR));
4159  /* exclude null from length */
4160  if (map->len) map->len--;
4161  map++;
4162  }
4163 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: _map.h:44
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519

Referenced by PathUnExpandEnvStringsW().

◆ PathAddBackslashA()

LPSTR WINAPI PathAddBackslashA ( LPSTR  lpszPath)

Definition at line 258 of file path.c.

259 {
260  size_t iLen;
261  LPSTR prev = lpszPath;
262 
263  TRACE("(%s)\n",debugstr_a(lpszPath));
264 
265  if (!lpszPath || (iLen = strlen(lpszPath)) >= MAX_PATH)
266  return NULL;
267 
268  if (iLen)
269  {
270  do {
271  lpszPath = CharNextA(prev);
272  if (*lpszPath)
273  prev = lpszPath;
274  } while (*lpszPath);
275  if (*prev != '\\')
276  {
277  *lpszPath++ = '\\';
278  *lpszPath = '\0';
279  }
280  }
281  return lpszPath;
282 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * LPSTR
Definition: xmlstorage.h:182
LPSTR WINAPI CharNextA(_In_ LPCSTR)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26

Referenced by ATL::CPathT< StringType >::PathAddBackslashX(), and test_PathAddBackslash().

◆ PathAddBackslashW()

LPWSTR WINAPI PathAddBackslashW ( LPWSTR  lpszPath)

Definition at line 289 of file path.c.

290 {
291  size_t iLen;
292 
293  TRACE("(%s)\n",debugstr_w(lpszPath));
294 
295  if (!lpszPath || (iLen = strlenW(lpszPath)) >= MAX_PATH)
296  return NULL;
297 
298  if (iLen)
299  {
300  lpszPath += iLen;
301  if (lpszPath[-1] != '\\')
302  {
303  *lpszPath++ = '\\';
304  *lpszPath = '\0';
305  }
306  }
307  return lpszPath;
308 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define MAX_PATH
Definition: compat.h:26

Referenced by CDesktopFolder::_GetSFFromPidl(), _SHGetUserShellFolderPath(), _SHRegisterFolders(), _SHRegisterUserShellFolders(), ACTION_AppSearchComponents(), ACTION_AppSearchDr(), ACTION_RecurseSearchDirectory(), ACTION_SearchDirectory(), app_search_file(), COMDLG32_GetCanonicalPath(), CControlPanelEnum::CreateCPanelEnumList(), FILEDLG95_InitControls(), FILEDLG95_ValidatePathAction(), find_published_source(), get_drive_type(), CFSFolder::GetDisplayNameOf(), CFileSysEnum::Initialize(), ITERATE_RemoveFiles(), MMSYS_InstallDevice(), msi_dialog_directorylist_up(), msi_load_media_info(), OpenColorProfileW(), CFSFolder::ParseDisplayName(), ATL::CPathT< StringType >::PathAddBackslashX(), PathCombineW(), PathIsDirectoryEmptyW(), ready_media(), RenderHDROP(), set_installer_properties(), SHCreateDirectoryExW(), ShellExecCmdLine(), ShellLink_UpdatePath(), SHGetFolderPathAndSubDirW(), SHGetNewLinkInfoW(), ShowCreateShortcutWizard(), source_matches_volume(), test_PathSearchAndQualify(), and wWinMain().

◆ PathAddExtensionA()

BOOL WINAPI PathAddExtensionA ( LPSTR  lpszPath,
LPCSTR  lpszExtension 
)

Definition at line 2594 of file path.c.

2595 {
2596  size_t dwLen;
2597 
2598  TRACE("(%s,%s)\n", debugstr_a(lpszPath), debugstr_a(lpszExtension));
2599 
2600  if (!lpszPath || !lpszExtension || *(PathFindExtensionA(lpszPath)))
2601  return FALSE;
2602 
2603  dwLen = strlen(lpszPath);
2604 
2605  if (dwLen + strlen(lpszExtension) >= MAX_PATH)
2606  return FALSE;
2607 
2608  strcpy(lpszPath + dwLen, lpszExtension);
2609  return TRUE;
2610 }
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
LPSTR WINAPI PathFindExtensionA(LPCSTR lpszPath)
Definition: path.c:417
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

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

◆ PathAddExtensionW()

BOOL WINAPI PathAddExtensionW ( LPWSTR  lpszPath,
LPCWSTR  lpszExtension 
)

Definition at line 2617 of file path.c.

2618 {
2619  size_t dwLen;
2620 
2621  TRACE("(%s,%s)\n", debugstr_w(lpszPath), debugstr_w(lpszExtension));
2622 
2623  if (!lpszPath || !lpszExtension || *(PathFindExtensionW(lpszPath)))
2624  return FALSE;
2625 
2626  dwLen = strlenW(lpszPath);
2627 
2628  if (dwLen + strlenW(lpszExtension) >= MAX_PATH)
2629  return FALSE;
2630 
2631  strcpyW(lpszPath + dwLen, lpszExtension);
2632  return TRUE;
2633 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define TRACE(s)
Definition: solgame.cpp:4
#define MAX_PATH
Definition: compat.h:26
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219

Referenced by ATL::CPathT< StringType >::PathAddExtensionX(), SHELL_TryAppPathW(), and WriteMinidump().

◆ PathAppendA()

BOOL WINAPI PathAppendA ( LPSTR  lpszPath,
LPCSTR  lpszAppend 
)

Definition at line 101 of file path.c.

102 {
103  TRACE("(%s,%s)\n",debugstr_a(lpszPath), debugstr_a(lpszAppend));
104 
105  if (lpszPath && lpszAppend)
106  {
107  if (!PathIsUNCA(lpszAppend))
108  while (*lpszAppend == '\\')
109  lpszAppend++;
110  if (PathCombineA(lpszPath, lpszPath, lpszAppend))
111  return TRUE;
112  }
113  return FALSE;
114 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LPSTR WINAPI PathCombineA(LPSTR lpszDest, LPCSTR lpszDir, LPCSTR lpszFile)
Definition: path.c:154
BOOL WINAPI PathIsUNCA(LPCSTR lpszPath)
Definition: path.c:2222

Referenced by PathAppendAW(), ATL::CPathT< StringType >::PathAppendX(), SHAddToRecentDocs(), test_PathAppendA(), test_SdbGetPermLayerKeys(), test_SetPermLayer(), and test_Sign_Media().

◆ PathAppendW()

BOOL WINAPI PathAppendW ( LPWSTR  lpszPath,
LPCWSTR  lpszAppend 
)

Definition at line 121 of file path.c.

122 {
123  TRACE("(%s,%s)\n",debugstr_w(lpszPath), debugstr_w(lpszAppend));
124 
125  if (lpszPath && lpszAppend)
126  {
127  if (!PathIsUNCW(lpszAppend))
128  while (*lpszAppend == '\\')
129  lpszAppend++;
130  if (PathCombineW(lpszPath, lpszPath, lpszAppend))
131  return TRUE;
132  }
133  return FALSE;
134 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
Definition: path.c:2245
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:189

Referenced by _SHExpandEnvironmentStrings(), _SHGetDefaultValue(), ACTION_RecurseSearchDirectory(), add_favs_to_menu(), addFileHelper(), CCommonFolder< CRegistryFolder, RegPidlEntry, CRegistryFolderExtractIcon >::BindToObject(), FinishDlgProc(), CFSFolder::GetCustomViewInfo(), CCommonFolder< CRegistryFolder, RegPidlEntry, CRegistryFolderExtractIcon >::GetDisplayNameOf(), getIconLocationForDrive(), getIconLocationForFolder(), CFileDefExt::InitFolderCustomizePage(), CFileDefExt::OnFolderCustApply(), PathAppendAW(), ATL::CPathT< StringType >::PathAppendX(), SHGetFolderPathAndSubDirW(), SHLWAPI_PathFindInOtherDirs(), and testRegStoreSavedCerts().

◆ PathBuildRootA()

LPSTR WINAPI PathBuildRootA ( LPSTR  lpszPath,
int  drive 
)

Definition at line 324 of file path.c.

325 {
326  TRACE("(%p,%d)\n", lpszPath, drive);
327 
328  if (lpszPath && drive >= 0 && drive < 26)
329  {
330  lpszPath[0] = 'A' + drive;
331  lpszPath[1] = ':';
332  lpszPath[2] = '\\';
333  lpszPath[3] = '\0';
334  }
335  return lpszPath;
336 }
#define TRACE(s)
Definition: solgame.cpp:4
static char drive[2]
Definition: batch.c:28

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

◆ PathBuildRootW()

LPWSTR WINAPI PathBuildRootW ( LPWSTR  lpszPath,
int  drive 
)

Definition at line 343 of file path.c.

344 {
345  TRACE("(%p,%d)\n", lpszPath, drive);
346 
347  if (lpszPath && drive >= 0 && drive < 26)
348  {
349  lpszPath[0] = 'A' + drive;
350  lpszPath[1] = ':';
351  lpszPath[2] = '\\';
352  lpszPath[3] = '\0';
353  }
354  return lpszPath;
355 }
#define TRACE(s)
Definition: solgame.cpp:4
static char drive[2]
Definition: batch.c:28

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

◆ PathCanonicalizeA()

BOOL WINAPI PathCanonicalizeA ( LPSTR  lpszBuf,
LPCSTR  lpszPath 
)

Definition at line 2392 of file path.c.

2393 {
2394  BOOL bRet = FALSE;
2395 
2396  TRACE("(%p,%s)\n", lpszBuf, debugstr_a(lpszPath));
2397 
2398  if (lpszBuf)
2399  *lpszBuf = '\0';
2400 
2401  if (!lpszBuf || !lpszPath)
2403  else
2404  {
2406  WCHAR szBuff[MAX_PATH];
2407  int ret = MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
2408 
2409  if (!ret) {
2410  WARN("Failed to convert string to widechar (too long?), LE %d.\n", GetLastError());
2411  return FALSE;
2412  }
2413  bRet = PathCanonicalizeW(szBuff, szPath);
2414  WideCharToMultiByte(CP_ACP,0,szBuff,-1,lpszBuf,MAX_PATH,0,0);
2415  }
2416  return bRet;
2417 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WideCharToMultiByte
Definition: compat.h:101
BOOL WINAPI PathCanonicalizeW(LPWSTR lpszBuf, LPCWSTR lpszPath)
Definition: path.c:2425
#define CP_ACP
Definition: compat.h:99
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD ret
Definition: path.c:47
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
LPCWSTR szPath
Definition: env.c:35
#define MultiByteToWideChar
Definition: compat.h:100

Referenced by ATL::CPathT< StringType >::PathCanonicalizeX(), and test_PathCanonicalizeA().

◆ PathCanonicalizeW()

BOOL WINAPI PathCanonicalizeW ( LPWSTR  lpszBuf,
LPCWSTR  lpszPath 
)

Definition at line 2425 of file path.c.

2426 {
2427  LPWSTR lpszDst = lpszBuf;
2428  LPCWSTR lpszSrc = lpszPath;
2429 
2430  TRACE("(%p,%s)\n", lpszBuf, debugstr_w(lpszPath));
2431 
2432  if (lpszBuf)
2433  *lpszDst = '\0';
2434 
2435  if (!lpszBuf || !lpszPath)
2436  {
2438  return FALSE;
2439  }
2440 
2441  if (!*lpszPath)
2442  {
2443  *lpszBuf++ = '\\';
2444  *lpszBuf = '\0';
2445  return TRUE;
2446  }
2447 
2448  /* Copy path root */
2449  if (*lpszSrc == '\\')
2450  {
2451  *lpszDst++ = *lpszSrc++;
2452  }
2453  else if (*lpszSrc && lpszSrc[1] == ':')
2454  {
2455  /* X:\ */
2456  *lpszDst++ = *lpszSrc++;
2457  *lpszDst++ = *lpszSrc++;
2458  if (*lpszSrc == '\\')
2459  *lpszDst++ = *lpszSrc++;
2460  }
2461 
2462  /* Canonicalize the rest of the path */
2463  while (*lpszSrc)
2464  {
2465  if (*lpszSrc == '.')
2466  {
2467  if (lpszSrc[1] == '\\' && (lpszSrc == lpszPath || lpszSrc[-1] == '\\' || lpszSrc[-1] == ':'))
2468  {
2469  lpszSrc += 2; /* Skip .\ */
2470  }
2471  else if (lpszSrc[1] == '.' && (lpszDst == lpszBuf || lpszDst[-1] == '\\'))
2472  {
2473  /* \.. backs up a directory, over the root if it has no \ following X:.
2474  * .. is ignored if it would remove a UNC server name or initial \\
2475  */
2476  if (lpszDst != lpszBuf)
2477  {
2478  *lpszDst = '\0'; /* Allow PathIsUNCServerShareA test on lpszBuf */
2479  if (lpszDst > lpszBuf+1 && lpszDst[-1] == '\\' &&
2480  (lpszDst[-2] != '\\' || lpszDst > lpszBuf+2))
2481  {
2482  if (lpszDst[-2] == ':' && (lpszDst > lpszBuf+3 || lpszDst[-3] == ':'))
2483  {
2484  lpszDst -= 2;
2485  while (lpszDst > lpszBuf && *lpszDst != '\\')
2486  lpszDst--;
2487  if (*lpszDst == '\\')
2488  lpszDst++; /* Reset to last '\' */
2489  else
2490  lpszDst = lpszBuf; /* Start path again from new root */
2491  }
2492  else if (lpszDst[-2] != ':' && !PathIsUNCServerShareW(lpszBuf))
2493  lpszDst -= 2;
2494  }
2495  while (lpszDst > lpszBuf && *lpszDst != '\\')
2496  lpszDst--;
2497  if (lpszDst == lpszBuf)
2498  {
2499  *lpszDst++ = '\\';
2500  lpszSrc++;
2501  }
2502  }
2503  lpszSrc += 2; /* Skip .. in src path */
2504  }
2505  else
2506  *lpszDst++ = *lpszSrc++;
2507  }
2508  else
2509  *lpszDst++ = *lpszSrc++;
2510  }
2511  /* Append \ to naked drive specs */
2512  if (lpszDst - lpszBuf == 2 && lpszDst[-1] == ':')
2513  *lpszDst++ = '\\';
2514  *lpszDst++ = '\0';
2515  return TRUE;
2516 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI PathIsUNCServerShareW(LPCWSTR lpszPath)
Definition: path.c:2357
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by COMDLG32_GetCanonicalPath(), PathCanonicalizeA(), ATL::CPathT< StringType >::PathCanonicalizeX(), and PathCombineW().

◆ PathCombineA()

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

Definition at line 154 of file path.c.

155 {
156  WCHAR szDest[MAX_PATH];
157  WCHAR szDir[MAX_PATH];
158  WCHAR szFile[MAX_PATH];
159  TRACE("(%p,%s,%s)\n", lpszDest, debugstr_a(lpszDir), debugstr_a(lpszFile));
160 
161  /* Invalid parameters */
162  if (!lpszDest)
163  return NULL;
164  if (!lpszDir && !lpszFile)
165  goto fail;
166 
167  if (lpszDir)
168  if (!MultiByteToWideChar(CP_ACP,0,lpszDir,-1,szDir,MAX_PATH))
169  goto fail;
170 
171  if (lpszFile)
172  if (!MultiByteToWideChar(CP_ACP,0,lpszFile,-1,szFile,MAX_PATH))
173  goto fail;
174 
175  if (PathCombineW(szDest, lpszDir ? szDir : NULL, lpszFile ? szFile : NULL))
176  if (WideCharToMultiByte(CP_ACP,0,szDest,-1,lpszDest,MAX_PATH,0,0))
177  return lpszDest;
178 
179 fail:
180  lpszDest[0] = 0;
181  return NULL;
182 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
WCHAR lpszDest[260]
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
#define MultiByteToWideChar
Definition: compat.h:100
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:189

Referenced by create_file(), delete_file(), expect_files(), CZipExtract::Extract(), PathAppendA(), ATL::CPathT< StringType >::PathCombineX(), test_items(), test_PathCombineA(), test_SdbGetPermLayerKeys(), test_Sign_Media(), and wrapSdbSetPermLayerKeys2().

◆ PathCombineW()

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

Definition at line 189 of file path.c.

190 {
191  WCHAR szTemp[MAX_PATH];
192  BOOL bUseBoth = FALSE, bStrip = FALSE;
193 
194  TRACE("(%p,%s,%s)\n", lpszDest, debugstr_w(lpszDir), debugstr_w(lpszFile));
195 
196  /* Invalid parameters */
197  if (!lpszDest)
198  return NULL;
199  if (!lpszDir && !lpszFile)
200  {
201  lpszDest[0] = 0;
202  return NULL;
203  }
204 
205  if ((!lpszFile || !*lpszFile) && lpszDir)
206  {
207  /* Use dir only */
208  lstrcpynW(szTemp, lpszDir, MAX_PATH);
209  }
210  else if (!lpszDir || !*lpszDir || !PathIsRelativeW(lpszFile))
211  {
212  if (!lpszDir || !*lpszDir || *lpszFile != '\\' || PathIsUNCW(lpszFile))
213  {
214  /* Use file only */
215  lstrcpynW(szTemp, lpszFile, MAX_PATH);
216  }
217  else
218  {
219  bUseBoth = TRUE;
220  bStrip = TRUE;
221  }
222  }
223  else
224  bUseBoth = TRUE;
225 
226  if (bUseBoth)
227  {
228  lstrcpynW(szTemp, lpszDir, MAX_PATH);
229  if (bStrip)
230  {
231  PathStripToRootW(szTemp);
232  lpszFile++; /* Skip '\' */
233  }
234  if (!PathAddBackslashW(szTemp) || strlenW(szTemp) + strlenW(lpszFile) >= MAX_PATH)
235  {
236  lpszDest[0] = 0;
237  return NULL;
238  }
239  strcatW(szTemp, lpszFile);
240  }
241 
242  PathCanonicalizeW(lpszDest, szTemp);
243  return lpszDest;
244 }
#define TRUE
Definition: types.h:120
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1558
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
BOOL WINAPI PathCanonicalizeW(LPWSTR lpszBuf, LPCWSTR lpszPath)
Definition: path.c:2425
#define lstrcpynW
Definition: compat.h:397
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:728
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:289
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
WCHAR lpszDest[260]
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
Definition: path.c:2245

Referenced by CFSFolder::_CreateShellExtInstance(), CFSDropTarget::_DoDrop(), CFSFolder::BindToObject(), BuildPathsList(), compat_catpath(), copy_dir_to_dir(), copy_file(), copy_to_dir(), move_dir_to_dir(), move_to_dir(), parse_file_list(), PathAppendW(), PathCombineA(), ATL::CPathT< StringType >::PathCombineX(), PathFindOnPathExA(), PathFindOnPathExW(), PathYetAnotherMakeUniqueName(), pBuildFileList(), SetChmPath(), CFSFolder::SetNameOf(), SHELL_DeleteDirectoryW(), SHGetFileInfoW(), test_items(), and test_PathCombineW().

◆ PathCommonPrefixA()

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

Definition at line 2730 of file path.c.

2731 {
2732  size_t iLen = 0;
2733  LPCSTR lpszIter1 = lpszFile1;
2734  LPCSTR lpszIter2 = lpszFile2;
2735 
2736  TRACE("(%s,%s,%p)\n", debugstr_a(lpszFile1), debugstr_a(lpszFile2), achPath);
2737 
2738  if (achPath)
2739  *achPath = '\0';
2740 
2741  if (!lpszFile1 || !lpszFile2)
2742  return 0;
2743 
2744  /* Handle roots first */
2745  if (PathIsUNCA(lpszFile1))
2746  {
2747  if (!PathIsUNCA(lpszFile2))
2748  return 0;
2749  lpszIter1 += 2;
2750  lpszIter2 += 2;
2751  }
2752  else if (PathIsUNCA(lpszFile2))
2753  return 0; /* Know already lpszFile1 is not UNC */
2754 
2755  do
2756  {
2757  /* Update len */
2758  if ((!*lpszIter1 || *lpszIter1 == '\\') &&
2759  (!*lpszIter2 || *lpszIter2 == '\\'))
2760  iLen = lpszIter1 - lpszFile1; /* Common to this point */
2761 
2762  if (!*lpszIter1 || (tolower(*lpszIter1) != tolower(*lpszIter2)))
2763  break; /* Strings differ at this point */
2764 
2765  lpszIter1++;
2766  lpszIter2++;
2767  } while (1);
2768 
2769  if (iLen == 2)
2770  iLen++; /* Feature/Bug compatible with Win32 */
2771 
2772  if (iLen && achPath)
2773  {
2774  memcpy(achPath,lpszFile1,iLen);
2775  achPath[iLen] = '\0';
2776  }
2777  return iLen;
2778 }
const char * LPCSTR
Definition: xmlstorage.h:183
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int tolower(int c)
Definition: utclib.c:902
BOOL WINAPI PathIsUNCA(LPCSTR lpszPath)
Definition: path.c:2222

Referenced by ATL::CPathT< StringType >::PathCommonPrefixX(), PathIsPrefixA(), PathIsSameRootA(), and test_PathCommonPrefixA().

◆ PathCommonPrefixW()

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

Definition at line 2785 of file path.c.

2786 {
2787  size_t iLen = 0;
2788  LPCWSTR lpszIter1 = lpszFile1;
2789  LPCWSTR lpszIter2 = lpszFile2;
2790 
2791  TRACE("(%s,%s,%p)\n", debugstr_w(lpszFile1), debugstr_w(lpszFile2), achPath);
2792 
2793  if (achPath)
2794  *achPath = '\0';
2795 
2796  if (!lpszFile1 || !lpszFile2)
2797  return 0;
2798 
2799  /* Handle roots first */
2800  if (PathIsUNCW(lpszFile1))
2801  {
2802  if (!PathIsUNCW(lpszFile2))
2803  return 0;
2804  lpszIter1 += 2;
2805  lpszIter2 += 2;
2806  }
2807  else if (PathIsUNCW(lpszFile2))
2808  return 0; /* Know already lpszFile1 is not UNC */
2809 
2810  do
2811  {
2812  /* Update len */
2813  if ((!*lpszIter1 || *lpszIter1 == '\\') &&
2814  (!*lpszIter2 || *lpszIter2 == '\\'))
2815  iLen = lpszIter1 - lpszFile1; /* Common to this point */
2816 
2817  if (!*lpszIter1 || (tolowerW(*lpszIter1) != tolowerW(*lpszIter2)))
2818  break; /* Strings differ at this point */
2819 
2820  lpszIter1++;
2821  lpszIter2++;
2822  } while (1);
2823 
2824  if (iLen == 2)
2825  iLen++; /* Feature/Bug compatible with Win32 */
2826 
2827  if (iLen && achPath)
2828  {
2829  memcpy(achPath,lpszFile1,iLen * sizeof(WCHAR));
2830  achPath[iLen] = '\0';
2831  }
2832  return iLen;
2833 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
WINE_UNICODE_INLINE WCHAR tolowerW(WCHAR ch)
Definition: unicode.h:135
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
Definition: path.c:2245

Referenced by ATL::CPathT< StringType >::PathCommonPrefixX(), PathIsPrefixW(), PathIsSameRootW(), and PathRelativePathToW().

◆ PathCompactPathA()

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

Definition at line 2849 of file path.c.

2850 {
2851  BOOL bRet = FALSE;
2852 
2853  TRACE("(%p,%s,%d)\n", hDC, debugstr_a(lpszPath), dx);
2854 
2855  if (lpszPath)
2856  {
2858  MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
2859  bRet = PathCompactPathW(hDC, szPath, dx);
2860  WideCharToMultiByte(CP_ACP,0,szPath,-1,lpszPath,MAX_PATH,0,0);
2861  }
2862  return bRet;
2863 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx)
Definition: path.c:2870
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
static HDC hDC
Definition: 3dtext.c:33
LPCWSTR szPath
Definition: env.c:35
GLint dx
Definition: linetemp.h:97
#define MultiByteToWideChar
Definition: compat.h:100

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

◆ PathCompactPathExA()

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

Definition at line 1414 of file path.c.

1416 {
1417  BOOL bRet = FALSE;
1418 
1419  TRACE("(%p,%s,%d,0x%08x)\n", lpszDest, debugstr_a(lpszPath), cchMax, dwFlags);
1420 
1421  if (lpszPath && lpszDest)
1422  {
1424  WCHAR szDest[MAX_PATH];
1425 
1426  MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
1427  szDest[0] = '\0';
1428  bRet = PathCompactPathExW(szDest, szPath, cchMax, dwFlags);
1429  WideCharToMultiByte(CP_ACP,0,szDest,-1,lpszDest,MAX_PATH,0,0);
1430  }
1431  return bRet;
1432 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
unsigned int BOOL
Definition: ntddk_ex.h:94
WCHAR lpszDest[260]
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
UINT cchMax
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPCWSTR szPath
Definition: env.c:35
BOOL WINAPI PathCompactPathExW(LPWSTR lpszDest, LPCWSTR lpszPath, UINT cchMax, DWORD dwFlags)
Definition: path.c:1439
#define MultiByteToWideChar
Definition: compat.h:100

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

◆ PathCompactPathExW()

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

Definition at line 1439 of file path.c.

1441 {
1442  static const WCHAR szEllipses[] = { '.', '.', '.', '\0' };
1443  LPCWSTR lpszFile;
1444  DWORD dwLen, dwFileLen = 0;
1445 
1446  TRACE("(%p,%s,%d,0x%08x)\n", lpszDest, debugstr_w(lpszPath), cchMax, dwFlags);
1447 
1448  if (!lpszPath)
1449  return FALSE;
1450 
1451  if (!lpszDest)
1452  {
1453  WARN("Invalid lpszDest would crash under Win32!\n");
1454  return FALSE;
1455  }
1456 
1457  *lpszDest = '\0';
1458 
1459  if (cchMax < 2)
1460  return TRUE;
1461 
1462  dwLen = strlenW(lpszPath) + 1;
1463 
1464  if (dwLen < cchMax)
1465  {
1466  /* Don't need to compact */
1467  memcpy(lpszDest, lpszPath, dwLen * sizeof(WCHAR));
1468  return TRUE;
1469  }
1470 
1471  /* Path must be compacted to fit into lpszDest */
1472  lpszFile = PathFindFileNameW(lpszPath);
1473  dwFileLen = lpszPath + dwLen - lpszFile;
1474 
1475  if (dwFileLen == dwLen)
1476  {
1477  /* No root in psth */
1478  if (cchMax <= 4)
1479  {
1480  while (--cchMax > 0) /* No room left for anything but ellipses */
1481  *lpszDest++ = '.';
1482  *lpszDest = '\0';
1483  return TRUE;
1484  }
1485  /* Compact the file name with ellipses at the end */
1486  cchMax -= 4;
1487  memcpy(lpszDest, lpszFile, cchMax * sizeof(WCHAR));
1488  strcpyW(lpszDest + cchMax, szEllipses);
1489  return TRUE;
1490  }
1491  /* We have a root in the path */
1492  lpszFile--; /* Start compacted filename with the path separator */
1493  dwFileLen++;
1494 
1495  if (dwFileLen + 3 > cchMax)
1496  {
1497  /* Compact the file name */
1498  if (cchMax <= 4)
1499  {
1500  while (--cchMax > 0) /* No room left for anything but ellipses */
1501  *lpszDest++ = '.';
1502  *lpszDest = '\0';
1503  return TRUE;
1504  }
1505  strcpyW(lpszDest, szEllipses);
1506  lpszDest += 3;
1507  cchMax -= 4;
1508  *lpszDest++ = *lpszFile++;
1509  if (cchMax <= 4)
1510  {
1511  while (--cchMax > 0) /* No room left for anything but ellipses */
1512  *lpszDest++ = '.';
1513  *lpszDest = '\0';
1514  return TRUE;
1515  }
1516  cchMax -= 4;
1517  memcpy(lpszDest, lpszFile, cchMax * sizeof(WCHAR));
1518  strcpyW(lpszDest + cchMax, szEllipses);
1519  return TRUE;
1520  }
1521 
1522  /* Only the root needs to be Compacted */
1523  dwLen = cchMax - dwFileLen - 3;
1524  memcpy(lpszDest, lpszPath, dwLen * sizeof(WCHAR));
1525  strcpyW(lpszDest + dwLen, szEllipses);
1526  strcpyW(lpszDest + dwLen + 3, lpszFile);
1527  return TRUE;
1528 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define WARN(fmt,...)
Definition: debug.h:111
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
WCHAR lpszDest[260]
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT cchMax
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219

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

◆ PathCompactPathW()

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

Definition at line 2870 of file path.c.

2871 {
2872  static const WCHAR szEllipses[] = { '.', '.', '.', '\0' };
2873  BOOL bRet = TRUE;
2874  HDC hdc = 0;
2875  WCHAR buff[MAX_PATH];
2876  SIZE size;
2877  DWORD dwLen;
2878 
2879  TRACE("(%p,%s,%d)\n", hDC, debugstr_w(lpszPath), dx);
2880 
2881  if (!lpszPath)
2882  return FALSE;
2883 
2884  if (!hDC)
2885  hdc = hDC = GetDC(0);
2886 
2887  /* Get the length of the whole path */
2888  dwLen = strlenW(lpszPath);
2889  GetTextExtentPointW(hDC, lpszPath, dwLen, &size);
2890 
2891  if ((UINT)size.cx > dx)
2892  {
2893  /* Path too big, must reduce it */
2894  LPWSTR sFile;
2895  DWORD dwEllipsesLen = 0, dwPathLen = 0;
2896 
2897  sFile = PathFindFileNameW(lpszPath);
2898  if (sFile != lpszPath) sFile--;
2899 
2900  /* Get the size of ellipses */
2901  GetTextExtentPointW(hDC, szEllipses, 3, &size);
2902  dwEllipsesLen = size.cx;
2903  /* Get the size of the file name */
2904  GetTextExtentPointW(hDC, sFile, strlenW(sFile), &size);
2905  dwPathLen = size.cx;
2906 
2907  if (sFile != lpszPath)
2908  {
2909  LPWSTR sPath = sFile;
2910  BOOL bEllipses = FALSE;
2911 
2912  /* The path includes a file name. Include as much of the path prior to
2913  * the file name as possible, allowing for the ellipses, e.g:
2914  * c:\some very long path\filename ==> c:\some v...\filename
2915  */
2916  lstrcpynW(buff, sFile, MAX_PATH);
2917 
2918  do
2919  {
2920  DWORD dwTotalLen = bEllipses? dwPathLen + dwEllipsesLen : dwPathLen;
2921 
2922  GetTextExtentPointW(hDC, lpszPath, sPath - lpszPath, &size);
2923  dwTotalLen += size.cx;
2924  if (dwTotalLen <= dx)
2925  break;
2926  sPath--;
2927  if (!bEllipses)
2928  {
2929  bEllipses = TRUE;
2930  sPath -= 2;
2931  }
2932  } while (sPath > lpszPath);
2933 
2934  if (sPath > lpszPath)
2935  {
2936  if (bEllipses)
2937  {
2938  strcpyW(sPath, szEllipses);
2939  strcpyW(sPath+3, buff);
2940  }
2941  bRet = TRUE;
2942  goto end;
2943  }
2944  strcpyW(lpszPath, szEllipses);
2945  strcpyW(lpszPath+3, buff);
2946  bRet = FALSE;
2947  goto end;
2948  }
2949 
2950  /* Trim the path by adding ellipses to the end, e.g:
2951  * A very long file name.txt ==> A very...
2952  */
2953  dwLen = strlenW(lpszPath);
2954 
2955  if (dwLen > MAX_PATH - 3)
2956  dwLen = MAX_PATH - 3;
2957  lstrcpynW(buff, sFile, dwLen);
2958 
2959  do {
2960  dwLen--;
2961  GetTextExtentPointW(hDC, buff, dwLen, &size);
2962  } while (dwLen && size.cx + dwEllipsesLen > dx);
2963 
2964  if (!dwLen)
2965  {
2966  DWORD dwWritten = 0;
2967 
2968  dwEllipsesLen /= 3; /* Size of a single '.' */
2969 
2970  /* Write as much of the Ellipses string as possible */
2971  while (dwWritten + dwEllipsesLen < dx && dwLen < 3)
2972  {
2973  *lpszPath++ = '.';
2974  dwWritten += dwEllipsesLen;
2975  dwLen++;
2976  }
2977  *lpszPath = '\0';
2978  bRet = FALSE;
2979  }
2980  else
2981  {
2982  strcpyW(buff + dwLen, szEllipses);
2983  strcpyW(lpszPath, buff);
2984  }
2985  }
2986 
2987 end:
2988  if (hdc)
2989  ReleaseDC(0, hdc);
2990 
2991  return bRet;
2992 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
GLuint GLuint end
Definition: gl.h:1545
#define lstrcpynW
Definition: compat.h:397
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
HDC hdc
Definition: main.c:9
static HDC hDC
Definition: 3dtext.c:33
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
unsigned int UINT
Definition: ndis.h:50
GLint dx
Definition: linetemp.h:97
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static unsigned char buff[32768]
Definition: fatten.c:17
BOOL WINAPI GetTextExtentPointW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)

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

3287 {
3288  WCHAR bufW[MAX_PATH];
3289  WCHAR *pathW = bufW;
3290  UNICODE_STRING urlW;
3291  HRESULT ret;
3292  DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
3293 
3294  if (!pszUrl || !pszPath || !pcchPath || !*pcchPath)
3295  return E_INVALIDARG;
3296 
3297  if(!RtlCreateUnicodeStringFromAsciiz(&urlW, pszUrl))
3298  return E_INVALIDARG;
3299  if((ret = PathCreateFromUrlW(urlW.Buffer, pathW, &lenW, dwReserved)) == E_POINTER) {
3300  pathW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
3301  ret = PathCreateFromUrlW(urlW.Buffer, pathW, &lenW, dwReserved);
3302  }
3303  if(ret == S_OK) {
3304  RtlUnicodeToMultiByteSize(&lenA, pathW, lenW * sizeof(WCHAR));
3305  if(*pcchPath > lenA) {
3306  RtlUnicodeToMultiByteN(pszPath, *pcchPath - 1, &lenA, pathW, lenW * sizeof(WCHAR));
3307  pszPath[lenA] = 0;
3308  *pcchPath = lenA;
3309  } else {
3310  *pcchPath = lenA + 1;
3311  ret = E_POINTER;
3312  }
3313  }
3314  if(pathW != bufW) HeapFree(GetProcessHeap(), 0, pathW);
3315  RtlFreeUnicodeString(&urlW);
3316  return ret;
3317 }
HRESULT WINAPI PathCreateFromUrlW(LPCWSTR pszUrl, LPWSTR pszPath, LPDWORD pcchPath, DWORD dwReserved)
Definition: path.c:3334
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteSize(PULONG MbSize, PCWCH UnicodeString, ULONG UnicodeSize)
DWORD ret
Definition: path.c:47
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define E_INVALIDARG
Definition: ddrawi.h:101
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static LPWSTR PDWORD pcchPath
Definition: asmcache.c:747
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
#define S_OK
Definition: intsafe.h:59
#define E_POINTER
Definition: winerror.h:2365
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by FileProtocolHandlerA().

◆ PathCreateFromUrlAlloc()

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

Definition at line 3476 of file path.c.

3478 {
3479  WCHAR pathW[MAX_PATH];
3480  DWORD size;
3481  HRESULT hr;
3482 
3483  size = MAX_PATH;
3484  hr = PathCreateFromUrlW(pszUrl, pathW, &size, dwReserved);
3485  if (SUCCEEDED(hr))
3486  {
3487  /* Yes, this is supposed to crash if pszPath is NULL */
3488  *pszPath = StrDupW(pathW);
3489  }
3490  return hr;
3491 }
HRESULT WINAPI PathCreateFromUrlW(LPCWSTR pszUrl, LPWSTR pszPath, LPDWORD pcchPath, DWORD dwReserved)
Definition: path.c:3334
HRESULT hr
Definition: shlfolder.c:183
LPWSTR WINAPI StrDupW(LPCWSTR lpszStr)
Definition: string.c:1089
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ PathCreateFromUrlW()

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

Definition at line 3334 of file path.c.

3336 {
3337  static const WCHAR file_colon[] = { 'f','i','l','e',':',0 };
3338  static const WCHAR localhost[] = { 'l','o','c','a','l','h','o','s','t',0 };
3339  DWORD nslashes, unescape, len;
3340  const WCHAR *src;
3341  WCHAR *tpath, *dst;
3342  HRESULT ret;
3343 
3344  TRACE("(%s,%p,%p,0x%08x)\n", debugstr_w(pszUrl), pszPath, pcchPath, dwReserved);
3345 
3346  if (!pszUrl || !pszPath || !pcchPath || !*pcchPath)
3347  return E_INVALIDARG;
3348 
3349  if (lstrlenW(pszUrl) < 5)
3350  return E_INVALIDARG;
3351 
3353  file_colon, 5) != CSTR_EQUAL)
3354  return E_INVALIDARG;
3355  pszUrl += 5;
3356  ret = S_OK;
3357 
3358  src = pszUrl;
3359  nslashes = 0;
3360  while (*src == '/' || *src == '\\') {
3361  nslashes++;
3362  src++;
3363  }
3364 
3365  /* We need a temporary buffer so we can compute what size to ask for.
3366  * We know that the final string won't be longer than the current pszUrl
3367  * plus at most two backslashes. All the other transformations make it
3368  * shorter.
3369  */
3370  len = 2 + lstrlenW(pszUrl) + 1;
3371  if (*pcchPath < len)
3372  tpath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3373  else
3374  tpath = pszPath;
3375 
3376  len = 0;
3377  dst = tpath;
3378  unescape = 1;
3379  switch (nslashes)
3380  {
3381  case 0:
3382  /* 'file:' + escaped DOS path */
3383  break;
3384  case 1:
3385  /* 'file:/' + escaped DOS path */
3386  /* fall through */
3387  case 3:
3388  /* 'file:///' (implied localhost) + escaped DOS path */
3389  if (!isalphaW(*src) || (src[1] != ':' && src[1] != '|'))
3390  src -= 1;
3391  break;
3392  case 2:
3394  src, 9, localhost, 9) == CSTR_EQUAL && (src[9] == '/' || src[9] == '\\'))
3395  {
3396  /* 'file://localhost/' + escaped DOS path */
3397  src += 10;
3398  }
3399  else if (isalphaW(*src) && (src[1] == ':' || src[1] == '|'))
3400  {
3401  /* 'file://' + unescaped DOS path */
3402  unescape = 0;
3403  }
3404  else
3405  {
3406  /* 'file://hostname:port/path' (where path is escaped)
3407  * or 'file:' + escaped UNC path (\\server\share\path)
3408  * The second form is clearly specific to Windows and it might
3409  * even be doing a network lookup to try to figure it out.
3410  */
3411  while (*src && *src != '/' && *src != '\\')
3412  src++;
3413  len = src - pszUrl;
3414  StrCpyNW(dst, pszUrl, len + 1);
3415  dst += len;
3416  if (*src && isalphaW(src[1]) && (src[2] == ':' || src[2] == '|'))
3417  {
3418  /* 'Forget' to add a trailing '/', just like Windows */
3419  src++;
3420  }
3421  }
3422  break;
3423  case 4:
3424  /* 'file://' + unescaped UNC path (\\server\share\path) */
3425  unescape = 0;
3426  if (isalphaW(*src) && (src[1] == ':' || src[1] == '|'))
3427  break;
3428  /* fall through */
3429  default:
3430  /* 'file:/...' + escaped UNC path (\\server\share\path) */
3431  src -= 2;
3432  }
3433 
3434  /* Copy the remainder of the path */
3435  len += lstrlenW(src);
3436  StrCpyW(dst, src);
3437 
3438  /* First do the Windows-specific path conversions */
3439  for (dst = tpath; *dst; dst++)
3440  if (*dst == '/') *dst = '\\';
3441  if (isalphaW(*tpath) && tpath[1] == '|')
3442  tpath[1] = ':'; /* c| -> c: */
3443 
3444  /* And only then unescape the path (i.e. escaped slashes are left as is) */
3445  if (unescape)
3446  {
3448  if (ret == S_OK)
3449  {
3450  /* When working in-place UrlUnescapeW() does not set len */
3451  len = lstrlenW(tpath);
3452  }
3453  }
3454 
3455  if (*pcchPath < len + 1)
3456  {
3457  ret = E_POINTER;
3458  *pcchPath = len + 1;
3459  }
3460  else
3461  {
3462  *pcchPath = len;
3463  if (tpath != pszPath)
3464  StrCpyW(pszPath, tpath);
3465  }
3466  if (tpath != pszPath)
3467  HeapFree(GetProcessHeap(), 0, tpath);
3468 
3469  TRACE("Returning (%u) %s\n", *pcchPath, debugstr_w(pszPath));
3470  return ret;
3471 }
#define URL_UNESCAPE_INPLACE
Definition: shlwapi.h:1224
LPWSTR WINAPI StrCpyNW(LPWSTR dst, LPCWSTR src, int count)
Definition: string.c:536
static const BYTE localhost[]
Definition: encode.c:1442
#define NORM_IGNORECASE
Definition: winnls.h:173
#define lstrlenW
Definition: compat.h:407
DWORD ret
Definition: path.c:47
HRESULT WINAPI UrlUnescapeW(LPWSTR pszUrl, LPWSTR pszUnescaped, LPDWORD pcchUnescaped, DWORD dwFlags)
Definition: url.c:1367
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BOOL unescape(WCHAR *str)
Definition: lex.c:269
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2275
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPWSTR PDWORD pcchPath
Definition: asmcache.c:747
static DWORD LPDWORD LPCSTR src
Definition: path.c:23
GLenum GLsizei len
Definition: glext.h:6722
#define CSTR_EQUAL
Definition: winnls.h:453
LPWSTR WINAPI StrCpyW(LPWSTR lpszStr, LPCWSTR lpszSrc)
Definition: string.c:514
GLenum src
Definition: glext.h:6340
#define LOCALE_INVARIANT
#define S_OK
Definition: intsafe.h:59
GLenum GLenum dst
Definition: glext.h:6340
WINE_UNICODE_INLINE int isalphaW(WCHAR wc)
Definition: unicode.h:195
#define E_POINTER
Definition: winerror.h:2365
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DocObjectService_FireBeforeNavigate2(), InternetCrackUrlW(), on_before_navigate2(), parse_path_from_url(), PathCreateFromUrlA(), PathCreateFromUrlAlloc(), and SHELL_execute().

◆ PathFileExistsA()

BOOL WINAPI PathFileExistsA ( LPCSTR  lpszPath)

Definition at line 1734 of file path.c.

1735 {
1736  UINT iPrevErrMode;
1737  DWORD dwAttr;
1738 
1739  TRACE("(%s)\n",debugstr_a(lpszPath));
1740 
1741  if (!lpszPath)
1742  return FALSE;
1743 
1744  /* Prevent a dialog box if path is on a disk that has been ejected. */
1745  iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1746  dwAttr = GetFileAttributesA(lpszPath);
1747  SetErrorMode(iPrevErrMode);
1748  return dwAttr != INVALID_FILE_ATTRIBUTES;
1749 }
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:753
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
unsigned int UINT
Definition: ndis.h:50

Referenced by PathFileExistsAW(), and ATL::CPathT< StringType >::PathFileExistsX().

◆ PathFileExistsAndAttributesA()

BOOL WINAPI PathFileExistsAndAttributesA ( LPCSTR  lpszPath,
DWORD dwAttr 
)

Definition at line 1785 of file path.c.

1786 {
1787  UINT iPrevErrMode;
1788  DWORD dwVal = 0;
1789 
1790  TRACE("(%s %p)\n", debugstr_a(lpszPath), dwAttr);
1791 
1792  if (dwAttr)
1793  *dwAttr = INVALID_FILE_ATTRIBUTES;
1794 
1795  if (!lpszPath)
1796  return FALSE;
1797 
1798  iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1799  dwVal = GetFileAttributesA(lpszPath);
1800  SetErrorMode(iPrevErrMode);
1801  if (dwAttr)
1802  *dwAttr = dwVal;
1803  return (dwVal != INVALID_FILE_ATTRIBUTES);
1804 }
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:753
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
unsigned int UINT
Definition: ndis.h:50

◆ PathFileExistsAndAttributesW()

BOOL WINAPI PathFileExistsAndAttributesW ( LPCWSTR  lpszPath,
DWORD dwAttr 
)

Definition at line 1811 of file path.c.

1812 {
1813  UINT iPrevErrMode;
1814  DWORD dwVal;
1815 
1816  TRACE("(%s %p)\n", debugstr_w(lpszPath), dwAttr);
1817 
1818  if (!lpszPath)
1819  return FALSE;
1820 
1821  iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1822  dwVal = GetFileAttributesW(lpszPath);
1823  SetErrorMode(iPrevErrMode);
1824  if (dwAttr)
1825  *dwAttr = dwVal;
1826  return (dwVal != INVALID_FILE_ATTRIBUTES);
1827 }
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:753
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
unsigned int UINT
Definition: ndis.h:50

◆ PathFileExistsDefExtA()

BOOL WINAPI PathFileExistsDefExtA ( LPSTR  lpszPath,
DWORD  dwWhich 
)

Definition at line 1174 of file path.c.

1175 {
1176  BOOL bRet = FALSE;
1177 
1178  TRACE("(%s,%d)\n", debugstr_a(lpszPath), dwWhich);
1179 
1180  if (lpszPath)
1181  {
1183  MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
1184  bRet = PathFileExistsDefExtW(szPath, dwWhich);
1185  if (bRet)
1186  WideCharToMultiByte(CP_ACP,0,szPath,-1,lpszPath,MAX_PATH,0,0);
1187  }
1188  return bRet;
1189 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1112
LPCWSTR szPath
Definition: env.c:35
#define MultiByteToWideChar
Definition: compat.h:100

◆ PathFileExistsDefExtW()

BOOL WINAPI PathFileExistsDefExtW ( LPWSTR  lpszPath,
DWORD  dwWhich 
)

Definition at line 1112 of file path.c.

1113 {
1114  static const WCHAR pszExts[][5] = { { '.', 'p', 'i', 'f', 0},
1115  { '.', 'c', 'o', 'm', 0},
1116  { '.', 'e', 'x', 'e', 0},
1117  { '.', 'b', 'a', 't', 0},
1118  { '.', 'l', 'n', 'k', 0},
1119  { '.', 'c', 'm', 'd', 0},
1120  { 0, 0, 0, 0, 0} };
1121 
1122  TRACE("(%s,%d)\n", debugstr_w(lpszPath), dwWhich);
1123 
1124  if (!lpszPath || PathIsUNCServerW(lpszPath) || PathIsUNCServerShareW(lpszPath))
1125  return FALSE;
1126 
1127  if (dwWhich)
1128  {
1129  LPCWSTR szExt = PathFindExtensionW(lpszPath);
1130  if (!*szExt || dwWhich & 0x40)
1131  {
1132  size_t iChoose = 0;
1133  int iLen = lstrlenW(lpszPath);
1134  if (iLen > (MAX_PATH - 5))
1135  return FALSE;
1136  while ( (dwWhich & 0x1) && pszExts[iChoose][0] )
1137  {
1138  lstrcpyW(lpszPath + iLen, pszExts[iChoose]);
1139  if (PathFileExistsW(lpszPath))
1140  return TRUE;
1141  iChoose++;
1142  dwWhich >>= 1;
1143  }
1144  *(lpszPath + iLen) = (WCHAR)'\0';
1145  return FALSE;
1146  }
1147  }
1148  return PathFileExistsW(lpszPath);
1149 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
#define lstrlenW
Definition: compat.h:407
BOOL WINAPI PathIsUNCServerShareW(LPCWSTR lpszPath)
Definition: path.c:2357
#define debugstr_w
Definition: kernel32.h:32
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1756
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define lstrcpyW
Definition: compat.h:406
BOOL WINAPI PathIsUNCServerW(LPCWSTR lpszPath)
Definition: path.c:2302

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

◆ PathFileExistsW()

BOOL WINAPI PathFileExistsW ( LPCWSTR  lpszPath)

Definition at line 1756 of file path.c.

1757 {
1758  UINT iPrevErrMode;
1759  DWORD dwAttr;
1760 
1761  TRACE("(%s)\n",debugstr_w(lpszPath));
1762 
1763  if (!lpszPath)
1764  return FALSE;
1765 
1766  iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1767  dwAttr = GetFileAttributesW(lpszPath);
1768  SetErrorMode(iPrevErrMode);
1769  return dwAttr != INVALID_FILE_ATTRIBUTES;
1770 }
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:753
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
unsigned int UINT
Definition: ndis.h:50

Referenced by CFSDropTarget::_GetUniqueFileName(), copy_dir_to_dir(), copy_file(), copy_file_to_file(), copy_files(), copy_to_dir(), create_dest_dirs(), FILEDLG95_InitControls(), FILEDLG95_OnOpen(), HACKISH_PathResolve(), CFileDefExt::InitOpensWithField(), LoadOSList(), move_files(), on_default_action(), CShellLink::OnNotify(), PathFileExistsAW(), PathFileExistsDefExtW(), ATL::CPathT< StringType >::PathFileExistsX(), PathYetAnotherMakeUniqueName(), SHExplorerParseCmdLine(), SHGetFolderPathAndSubDirW(), SHGetWebFolderFilePathW(), and try_find_new_name().

◆ PathFindExtensionA()

LPSTR WINAPI PathFindExtensionA ( LPCSTR  lpszPath)

Definition at line 417 of file path.c.

418 {
419  LPCSTR lastpoint = NULL;
420 
421  TRACE("(%s)\n", debugstr_a(lpszPath));
422 
423  if (lpszPath)
424  {
425  while (*lpszPath)
426  {
427  if (*lpszPath == '\\' || *lpszPath==' ')
428  lastpoint = NULL;
429  else if (*lpszPath == '.')
430  lastpoint = lpszPath;
431  lpszPath = CharNextA(lpszPath);
432  }
433  }
434  return (LPSTR)(lastpoint ? lastpoint : lpszPath);
435 }
char * LPSTR
Definition: xmlstorage.h:182
LPSTR WINAPI CharNextA(_In_ LPCSTR)
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

Referenced by _ILGetExtension(), FD31_UpdateResult(), FILEDLG95_OnOpen(), PathAddExtensionA(), ATL::CPathT< StringType >::PathFindExtensionX(), PathGetExtensionA(), PathIsContentTypeA(), PathRemoveExtensionA(), PathRenameExtensionA(), PathUndecorateA(), and test_PathFindExtensionA().

◆ PathFindExtensionW()

LPWSTR WINAPI PathFindExtensionW ( LPCWSTR  lpszPath)

Definition at line 442 of file path.c.

443 {
444  LPCWSTR lastpoint = NULL;
445 
446  TRACE("(%s)\n", debugstr_w(lpszPath));
447 
448  if (lpszPath)
449  {
450  while (*lpszPath)
451  {
452  if (*lpszPath == '\\' || *lpszPath==' ')
453  lastpoint = NULL;
454  else if (*lpszPath == '.')
455  lastpoint = lpszPath;
456  lpszPath++;
457  }
458  }
459  return (LPWSTR)(lastpoint ? lastpoint : lpszPath);
460 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CFSDropTarget::_DoDrop(), add_favs_to_menu(), COpenWithList::AddAppToMRUList(), CFSFolder::CompareIDs(), CRecycleBin::CompareIDs(), CreateShortcut(), FD31_UpdateResult(), FILEDLG95_OnOpen(), FinishDlgProc(), FM_InitMenuPopup(), get_first_ext_from_spec(), CRecycleBin::GetDetailsOf(), CLayerUIPropPage::InitFile(), CFileDefExt::InitFileType(), COpenWithMenu::Initialize(), CFileDefExt::InitOpensWithField(), COpenWithMenu::InvokeCommand(), LoadPropSheetHandlers(), COpenWithList::LoadRecommended(), on_default_action(), CShellLink::OnNotify(), OpenKeyFromFileType(), PathAddExtensionW(), PathFileExistsDefExtW(), ATL::CPathT< StringType >::PathFindExtensionX(), PathGetExtensionW(), PathIsContentTypeW(), PathRemoveExtensionW(), PathRenameExtensionW(), PathUndecorateW(), PathYetAnotherMakeUniqueName(), process_extensions(), BtrfsContextMenu::reflink_copy(), COpenWithList::SetDefaultHandler(), CFSFolder::SetNameOf(), SH_GetTargetTypeByPath(), SHELL_FS_HideExtension(), ShellExecute_GetClassKey(), SHGetFileInfoW(), ShowCreateShortcutWizard(), try_find_new_name(), and URLDownloadToCacheFileW().

◆ PathFindFileNameA()

LPSTR WINAPI PathFindFileNameA ( LPCSTR  lpszPath)

Definition at line 368 of file path.c.

369 {
370  LPCSTR lastSlash = lpszPath;
371 
372  TRACE("(%s)\n",debugstr_a(lpszPath));
373 
374  while (lpszPath && *lpszPath)
375  {
376  if ((*lpszPath == '\\' || *lpszPath == '/' || *lpszPath == ':') &&
377  lpszPath[1] && lpszPath[1] != '\\' && lpszPath[1] != '/')
378  lastSlash = lpszPath + 1;
379  lpszPath = CharNextA(lpszPath);
380  }
381  return (LPSTR)lastSlash;
382 }
char * LPSTR
Definition: xmlstorage.h:182
LPSTR WINAPI CharNextA(_In_ LPCSTR)
const char * LPCSTR
Definition: xmlstorage.h:183
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

Referenced by _CZipAskPassword(), _CZipAskReplace(), FD31_UpdateResult(), FILEDLG95_OnOpen(), GetFileDialog95(), ATL::CPathT< StringType >::PathFindFileNameX(), and PathStripPathA().

◆ PathFindFileNameW()

LPWSTR WINAPI PathFindFileNameW ( LPCWSTR  lpszPath)

Definition at line 389 of file path.c.

390 {
391  LPCWSTR lastSlash = lpszPath;
392 
393  TRACE("(%s)\n",debugstr_w(lpszPath));
394 
395  while (lpszPath && *lpszPath)
396  {
397  if ((*lpszPath == '\\' || *lpszPath == '/' || *lpszPath == ':') &&
398  lpszPath[1] && lpszPath[1] != '\\' && lpszPath[1] != '/')
399  lastSlash = lpszPath + 1;
400  lpszPath++;
401  }
402  return (LPWSTR)lastSlash;
403 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CFSDropTarget::_DoDrop(), COpenWithList::Add(), CRecycleBin::CompareIDs(), copy_file(), copy_file_to_file(), create_target_directory(), FD31_UpdateResult(), FILEDLG95_OnOpen(), CFileDefExt::GeneralPageProc(), get_volume_path_parent(), GetFileDialog95(), CShellLink::GetPath(), COpenWithDialog::Init(), CFileDefExt::InitFilePath(), CFileDefExt::InitGeneralPage(), CFileDefExt::InitOpensWithField(), COpenWithList::LoadFromProgIdKey(), LoadPropSheetHandlers(), msi_dialog_directorylist_up(), CShellLink::OnInitDialog(), PathCompactPathExW(), PathCompactPathW(), ATL::CPathT< StringType >::PathFindFileNameX(), PathStripPathW(), BtrfsContextMenu::reflink_copy(), SH_ShowPropertiesDialog(), SHChangeNotify(), SHGetFileInfoW(), ShowCreateShortcutWizard(), and WelcomeDlgProc().

◆ PathFindNextComponentA()

LPSTR WINAPI PathFindNextComponentA ( LPCSTR  lpszPath)

Definition at line 2535 of file path.c.

2536 {
2537  LPSTR lpszSlash;
2538 
2539  TRACE("(%s)\n", debugstr_a(lpszPath));
2540 
2541  if(!lpszPath || !*lpszPath)
2542  return NULL;
2543 
2544  if ((lpszSlash = StrChrA(lpszPath, '\\')))
2545  {
2546  if (lpszSlash[1] == '\\')
2547  lpszSlash++;
2548  return lpszSlash + 1;
2549  }
2550  return (LPSTR)lpszPath + strlen(lpszPath);
2551 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * LPSTR
Definition: xmlstorage.h:182
LPSTR WINAPI StrChrA(LPCSTR lpszStr, WORD ch)
Definition: string.c:270
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

◆ PathFindNextComponentW()

LPWSTR WINAPI PathFindNextComponentW ( LPCWSTR  lpszPath)

Definition at line 2558 of file path.c.

2559 {
2560  LPWSTR lpszSlash;
2561 
2562  TRACE("(%s)\n", debugstr_w(lpszPath));
2563 
2564  if(!lpszPath || !*lpszPath)
2565  return NULL;
2566 
2567  if ((lpszSlash = StrChrW(lpszPath, '\\')))
2568  {
2569  if (lpszSlash[1] == '\\')
2570  lpszSlash++;
2571  return lpszSlash + 1;
2572  }
2573  return (LPWSTR)lpszPath + strlenW(lpszPath);
2574 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:468
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by FILEDLG95_ValidatePathAction(), and PathRelativePathToW().

◆ PathFindOnPathA()

BOOL WINAPI PathFindOnPathA ( LPSTR  lpszFile,
LPCSTR lppszOtherDirs 
)

Definition at line 1371 of file path.c.

1372 {
1373  TRACE("(%s,%p)\n", debugstr_a(lpszFile), lppszOtherDirs);
1374  return PathFindOnPathExA(lpszFile, lppszOtherDirs, 0);
1375  }
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
BOOL WINAPI PathFindOnPathExA(LPSTR lpszFile, LPCSTR *lppszOtherDirs, DWORD dwWhich)
Definition: path.c:1286

◆ PathFindOnPathExA()

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

Definition at line 1286 of file path.c.

1287 {
1288  WCHAR szFile[MAX_PATH];
1289  WCHAR buff[MAX_PATH];
1290 
1291  TRACE("(%s,%p,%08x)\n", debugstr_a(lpszFile), lppszOtherDirs, dwWhich);
1292 
1293  if (!lpszFile || !PathIsFileSpecA(lpszFile))
1294  return FALSE;
1295 
1296  MultiByteToWideChar(CP_ACP,0,lpszFile,-1,szFile,MAX_PATH);
1297 
1298  /* Search provided directories first */
1299  if (lppszOtherDirs && *lppszOtherDirs)
1300  {
1301  WCHAR szOther[MAX_PATH];
1302  LPCSTR *lpszOtherPath = lppszOtherDirs;
1303 
1304  while (lpszOtherPath && *lpszOtherPath && (*lpszOtherPath)[0])
1305  {
1306  MultiByteToWideChar(CP_ACP,0,*lpszOtherPath,-1,szOther,MAX_PATH);
1307  PathCombineW(buff, szOther, szFile);
1308  if (PathFileExistsDefExtW(buff, dwWhich))
1309  {
1310  WideCharToMultiByte(CP_ACP,0,buff,-1,lpszFile,MAX_PATH,0,0);
1311  return TRUE;
1312  }
1313  lpszOtherPath++;
1314  }
1315  }
1316  /* Not found, try system and path dirs */
1317  if (SHLWAPI_PathFindInOtherDirs(szFile, dwWhich))
1318  {
1319  WideCharToMultiByte(CP_ACP,0,szFile,-1,lpszFile,MAX_PATH,0,0);
1320  return TRUE;
1321  }
1322  return FALSE;
1323 }
#define TRUE
Definition: types.h:120
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
const char * LPCSTR
Definition: xmlstorage.h:183
BOOL WINAPI PathIsFileSpecA(LPCSTR lpszPath)
Definition: path.c:2091
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
static BOOL SHLWAPI_PathFindInOtherDirs(LPWSTR lpszFile, DWORD dwWhich)
Definition: path.c:1196
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1112
#define MultiByteToWideChar
Definition: compat.h:100
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:189
static unsigned char buff[32768]
Definition: fatten.c:17

Referenced by PathFindOnPathA().

◆ PathFindOnPathExW()

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

Definition at line 1330 of file path.c.

1331 {
1332  WCHAR buff[MAX_PATH];
1333 
1334  TRACE("(%s,%p,%08x)\n", debugstr_w(lpszFile), lppszOtherDirs, dwWhich);
1335 
1336  if (!lpszFile || !PathIsFileSpecW(lpszFile))
1337  return FALSE;
1338 
1339  /* Search provided directories first */
1340  if (lppszOtherDirs && *lppszOtherDirs)
1341  {
1342  LPCWSTR *lpszOtherPath = lppszOtherDirs;
1343  while (lpszOtherPath && *lpszOtherPath && (*lpszOtherPath)[0])
1344  {
1345  PathCombineW(buff, *lpszOtherPath, lpszFile);
1346  if (PathFileExistsDefExtW(buff, dwWhich))
1347  {
1348  strcpyW(lpszFile, buff);
1349  return TRUE;
1350  }
1351  lpszOtherPath++;
1352  }
1353  }
1354  /* Not found, try system and path dirs */
1355  return SHLWAPI_PathFindInOtherDirs(lpszFile, dwWhich);
1356 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define debugstr_w
Definition: kernel32.h:32
BOOL WINAPI PathIsFileSpecW(LPCWSTR lpszPath)
Definition: path.c:2112
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static BOOL SHLWAPI_PathFindInOtherDirs(LPWSTR lpszFile, DWORD dwWhich)
Definition: path.c:1196
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1112
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:189
static unsigned char buff[32768]
Definition: fatten.c:17

Referenced by PathFindOnPathW().

◆ PathFindOnPathW()

BOOL WINAPI PathFindOnPathW ( LPWSTR  lpszFile,
LPCWSTR lppszOtherDirs 
)

Definition at line 1382 of file path.c.

1383 {
1384  TRACE("(%s,%p)\n", debugstr_w(lpszFile), lppszOtherDirs);
1385  return PathFindOnPathExW(lpszFile,lppszOtherDirs, 0);
1386 }
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI PathFindOnPathExW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs, DWORD dwWhich)
Definition: path.c:1330

Referenced by DoEntry(), and HACKISH_PathResolve().

◆ PathFindSuffixArrayA()

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

Definition at line 3972 of file path.c.

3973 {
3974  size_t dwLen;
3975  int dwRet = 0;
3976 
3977  TRACE("(%s,%p,%d)\n",debugstr_a(lpszSuffix), lppszArray, dwCount);
3978 
3979  if (lpszSuffix && lppszArray && dwCount > 0)
3980  {
3981  dwLen = strlen(lpszSuffix);
3982 
3983  while (dwRet < dwCount)
3984  {
3985  size_t dwCompareLen = strlen(*lppszArray);
3986  if (dwCompareLen < dwLen)
3987  {
3988  if (!strcmp(lpszSuffix + dwLen - dwCompareLen, *lppszArray))
3989  return *lppszArray; /* Found */
3990  }
3991  dwRet++;
3992  lppszArray++;
3993  }
3994  }
3995  return NULL;
3996 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

◆ PathFindSuffixArrayW()

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

Definition at line 4003 of file path.c.

4004 {
4005  size_t dwLen;
4006  int dwRet = 0;
4007 
4008  TRACE("(%s,%p,%d)\n",debugstr_w(lpszSuffix), lppszArray, dwCount);
4009 
4010  if (lpszSuffix && lppszArray && dwCount > 0)
4011  {
4012  dwLen = strlenW(lpszSuffix);
4013 
4014  while (dwRet < dwCount)
4015  {
4016  size_t dwCompareLen = strlenW(*lppszArray);
4017  if (dwCompareLen < dwLen)
4018  {
4019  if (!strcmpW(lpszSuffix + dwLen - dwCompareLen, *lppszArray))
4020  return *lppszArray; /* Found */
4021  }
4022  dwRet++;
4023  lppszArray++;
4024  }
4025  }
4026  return NULL;
4027 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229

◆ PathGetArgsA()

LPSTR WINAPI PathGetArgsA ( LPCSTR  lpszPath)

Definition at line 476 of file path.c.

477 {
478  BOOL bSeenQuote = FALSE;
479 
480  TRACE("(%s)\n",debugstr_a(lpszPath));
481 
482  if (lpszPath)
483  {
484  while (*lpszPath)
485  {
486  if ((*lpszPath==' ') && !bSeenQuote)
487  return (LPSTR)lpszPath + 1;
488  if (*lpszPath == '"')
489  bSeenQuote = !bSeenQuote;
490  lpszPath = CharNextA(lpszPath);
491  }
492  }
493  return (LPSTR)lpszPath;
494 }
char * LPSTR
Definition: xmlstorage.h:182
LPSTR WINAPI CharNextA(_In_ LPCSTR)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

Referenced by PathRemoveArgsA().

◆ PathGetArgsW()

LPWSTR WINAPI PathGetArgsW ( LPCWSTR  lpszPath)

Definition at line 501 of file path.c.

502 {
503  BOOL bSeenQuote = FALSE;
504 
505  TRACE("(%s)\n",debugstr_w(lpszPath));
506 
507  if (lpszPath)
508  {
509  while (*lpszPath)
510  {
511  if ((*lpszPath==' ') && !bSeenQuote)
512  return (LPWSTR)lpszPath + 1;
513  if (*lpszPath == '"')
514  bSeenQuote = !bSeenQuote;
515  lpszPath++;
516  }
517  }
518  return (LPWSTR)lpszPath;
519 }
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CShellLink::OnNotify(), PathRemoveArgsW(), and SHExplorerParseCmdLine().

◆ PathGetCharTypeA()

UINT WINAPI PathGetCharTypeA ( UCHAR  ch)

Definition at line 3005 of file path.c.

3006 {
3007  return PathGetCharTypeW(ch);
3008 }
UINT WINAPI PathGetCharTypeW(WCHAR ch)
Definition: path.c:3015

Referenced by PathCleanupSpec().

◆ PathGetCharTypeW()

UINT WINAPI PathGetCharTypeW ( WCHAR  ch)

Definition at line 3015 of file path.c.

3016 {
3017  UINT flags = 0;
3018 
3019  TRACE("(%d)\n", ch);
3020 
3021  if (!ch || ch < ' ' || ch == '<' || ch == '>' ||
3022  ch == '"' || ch == '|' || ch == '/')
3023  flags = GCT_INVALID; /* Invalid */
3024  else if (ch == '*' || ch=='?')
3025  flags = GCT_WILD; /* Wildchars */
3026  else if ((ch == '\\') || (ch == ':'))
3027  return GCT_SEPARATOR; /* Path separators */
3028  else
3029  {
3030  if (ch < 126)
3031  {
3032  if (((ch & 0x1) && ch != ';') || !ch || isalnum(ch) || ch == '$' || ch == '&' || ch == '(' ||
3033  ch == '.' || ch == '@' || ch == '^' ||
3034  ch == '\'' || ch == 130 || ch == '`')
3035  flags |= GCT_SHORTCHAR; /* All these are valid for DOS */
3036  }
3037  else
3038  flags |= GCT_SHORTCHAR; /* Bug compatible with win32 */
3039  flags |= GCT_LFNCHAR; /* Valid for long file names */
3040  }
3041  return flags;
3042 }
#define GCT_LFNCHAR
Definition: shlwapi.h:776
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
_Check_return_ _CRTIMP int __cdecl isalnum(_In_ int _C)
#define GCT_WILD
Definition: shlwapi.h:778
#define GCT_INVALID
Definition: shlwapi.h:775
#define GCT_SHORTCHAR
Definition: shlwapi.h:777
#define TRACE(s)
Definition: solgame.cpp:4
#define GCT_SEPARATOR
Definition: shlwapi.h:779
GLbitfield flags
Definition: glext.h:7161
unsigned int UINT
Definition: ndis.h:50

Referenced by PathCleanupSpec(), and PathGetCharTypeA().

◆ PathGetDriveNumberA()

int WINAPI PathGetDriveNumberA ( LPCSTR  lpszPath)

Definition at line 533 of file path.c.

534 {
535  TRACE ("(%s)\n",debugstr_a(lpszPath));
536 
537  if (lpszPath && !IsDBCSLeadByte(*lpszPath) && lpszPath[1] == ':' &&
538  tolower(*lpszPath) >= 'a' && tolower(*lpszPath) <= 'z')
539  return tolower(*lpszPath) - 'a';
540  return -1;
541 }
BOOL WINAPI IsDBCSLeadByte(BYTE TestByte)
Definition: nls.c:2221
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
int tolower(int c)
Definition: utclib.c:902

Referenced by ATL::CPathT< StringType >::PathGetDriveNumberX(), PathIsNetworkPathA(), and test_PathGetDriveNumber().

◆ PathGetDriveNumberW()

int WINAPI PathGetDriveNumberW ( const WCHAR path)

Definition at line 548 of file path.c.

549 {
550  WCHAR drive;
551 
552  static const WCHAR nt_prefixW[] = {'\\','\\','?','\\'};
553 
554  TRACE("(%s)\n", debugstr_w(path));
555 
556  if (!path)
557  return -1;
558 
559  if (!strncmpW(path, nt_prefixW, 4))
560  path += 4;
561 
562  drive = tolowerW(path[0]);
563  if (drive < 'a' || drive > 'z' || path[1] != ':')
564  return -1;
565 
566  return drive - 'a';
567 }
WINE_UNICODE_INLINE int strncmpW(const WCHAR *str1, const WCHAR *str2, int n)
Definition: unicode.h:235
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
WINE_UNICODE_INLINE WCHAR tolowerW(WCHAR ch)
Definition: unicode.h:135
static char drive[2]
Definition: batch.c:28
Definition: services.c:325

Referenced by COMDLG32_GetCanonicalPath(), CDrivesFolder::ParseDisplayName(), CDesktopFolder::ParseDisplayName(), ATL::CPathT< StringType >::PathGetDriveNumberX(), PathIsNetworkPathW(), and test_PathGetDriveNumber().

◆ PathIsContentTypeA()

BOOL WINAPI PathIsContentTypeA ( LPCSTR  lpszPath,
LPCSTR  lpszContentType 
)

Definition at line 2037 of file path.c.

2038 {
2039  LPCSTR szExt;
2040  DWORD dwDummy;
2041  char szBuff[MAX_PATH];
2042 
2043  TRACE("(%s,%s)\n", debugstr_a(lpszPath), debugstr_a(lpszContentType));
2044 
2045  if (lpszPath && (szExt = PathFindExtensionA(lpszPath)) && *szExt &&
2046  !SHGetValueA(HKEY_CLASSES_ROOT, szExt, "Content Type",
2047  REG_NONE, szBuff, &dwDummy) &&
2048  !strcasecmp(lpszContentType, szBuff))
2049  {
2050  return TRUE;
2051  }
2052  return FALSE;
2053 }
#define TRUE
Definition: types.h:120
#define strcasecmp
Definition: fake.h:9
const char * LPCSTR
Definition: xmlstorage.h:183
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI PathFindExtensionA(LPCSTR lpszPath)
Definition: path.c:417
DWORD WINAPI SHGetValueA(HKEY hKey, LPCSTR lpszSubKey, LPCSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1207
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define REG_NONE
Definition: nt_native.h:1492

◆ PathIsContentTypeW()

BOOL WINAPI PathIsContentTypeW ( LPCWSTR  lpszPath,
LPCWSTR  lpszContentType 
)

Definition at line 2060 of file path.c.

2061 {
2062  static const WCHAR szContentType[] = { 'C','o','n','t','e','n','t',' ','T','y','p','e','\0' };
2063  LPCWSTR szExt;
2064  DWORD dwDummy;
2065  WCHAR szBuff[MAX_PATH];
2066 
2067  TRACE("(%s,%s)\n", debugstr_w(lpszPath), debugstr_w(lpszContentType));
2068 
2069  if (lpszPath && (szExt = PathFindExtensionW(lpszPath)) && *szExt &&
2070  !SHGetValueW(HKEY_CLASSES_ROOT, szExt, szContentType,
2071  REG_NONE, szBuff, &dwDummy) &&
2072  !strcmpiW(lpszContentType, szBuff))
2073  {
2074  return TRUE;
2075  }
2076  return FALSE;
2077 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define REG_NONE
Definition: nt_native.h:1492

◆ PathIsDirectoryA()

BOOL WINAPI PathIsDirectoryA ( LPCSTR  lpszPath)

Definition at line 1677 of file path.c.

1678 {
1679  DWORD dwAttr;
1680 
1681  TRACE("(%s)\n", debugstr_a(lpszPath));
1682 
1683  if (!lpszPath || PathIsUNCServerA(lpszPath))
1684  return FALSE;
1685 
1686  if (PathIsUNCServerShareA(lpszPath))
1687  {
1688  FIXME("UNC Server Share not yet supported - FAILING\n");
1689  return FALSE;
1690  }
1691 
1692  if ((dwAttr = GetFileAttributesA(lpszPath)) == INVALID_FILE_ATTRIBUTES)
1693  return FALSE;
1694  return dwAttr & FILE_ATTRIBUTE_DIRECTORY;
1695 }
BOOL WINAPI PathIsUNCServerShareA(LPCSTR lpszPath)
Definition: path.c:2330
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
#define FIXME(fmt,...)
Definition: debug.h:110
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
BOOL WINAPI PathIsUNCServerA(LPCSTR lpszPath)
Definition: path.c:2280
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

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

◆ PathIsDirectoryEmptyA()

BOOL WINAPI PathIsDirectoryEmptyA ( LPCSTR  lpszPath)

Definition at line 3890 of file path.c.

3891 {
3892  BOOL bRet = FALSE;
3893 
3894  TRACE("(%s)\n",debugstr_a(lpszPath));
3895 
3896  if (lpszPath)
3897  {
3899  MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
3900  bRet = PathIsDirectoryEmptyW(szPath);
3901  }
3902  return bRet;
3903 }
#define CP_ACP
Definition: compat.h:99
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath)
Definition: path.c:3910
LPCWSTR szPath
Definition: env.c:35
#define MultiByteToWideChar
Definition: compat.h:100

◆ PathIsDirectoryEmptyW()

BOOL WINAPI PathIsDirectoryEmptyW ( LPCWSTR  lpszPath)

Definition at line 3910 of file path.c.

3911 {
3912  static const WCHAR szAllFiles[] = { '*', '.', '*', '\0' };
3913  WCHAR szSearch[MAX_PATH];
3914  DWORD dwLen;
3915  HANDLE hfind;
3916  BOOL retVal = TRUE;
3918 
3919  TRACE("(%s)\n",debugstr_w(lpszPath));
3920 
3921  if (!lpszPath || !PathIsDirectoryW(lpszPath))
3922  return FALSE;
3923 
3924  lstrcpynW(szSearch, lpszPath, MAX_PATH);
3925  PathAddBackslashW(szSearch);
3926  dwLen = strlenW(szSearch);
3927  if (dwLen > MAX_PATH - 4)
3928  return FALSE;
3929 
3930  strcpyW(szSearch + dwLen, szAllFiles);
3931  hfind = FindFirstFileW(szSearch, &find_data);
3932  if (hfind == INVALID_HANDLE_VALUE)
3933  return FALSE;
3934 
3935  do
3936  {
3937  if (find_data.cFileName[0] == '.')
3938  {
3939  if (find_data.cFileName[1] == '\0') continue;
3940  if (find_data.cFileName[1] == '.' && find_data.cFileName[2] == '\0') continue;
3941  }
3942 
3943  retVal = FALSE;
3944  break;
3945  }
3946  while (FindNextFileW(hfind, &find_data));
3947 
3948  FindClose(hfind);
3949  return retVal;
3950 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1702
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static int find_data(const struct Vector *v, const BYTE *pData, int size)
Definition: filtermapper.c:162
#define lstrcpynW
Definition: compat.h:397
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:289
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by move_dir_to_dir(), and PathIsDirectoryEmptyA().

◆ PathIsDirectoryW()

BOOL WINAPI PathIsDirectoryW ( LPCWSTR  lpszPath)

Definition at line 1702 of file path.c.

1703 {
1704  DWORD dwAttr;
1705 
1706  TRACE("(%s)\n", debugstr_w(lpszPath));
1707 
1708  if (!lpszPath || PathIsUNCServerW(lpszPath))
1709  return FALSE;
1710 
1711  if (PathIsUNCServerShareW(lpszPath))
1712  {
1713  FIXME("UNC Server Share not yet supported - FAILING\n");
1714  return FALSE;
1715  }
1716 
1717  if ((dwAttr = GetFileAttributesW(lpszPath)) == INVALID_FILE_ATTRIBUTES)
1718  return FALSE;
1719  return dwAttr & FILE_ATTRIBUTE_DIRECTORY;
1720 }
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
BOOL WINAPI PathIsUNCServerShareW(LPCWSTR lpszPath)
Definition: path.c:2357
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
BOOL WINAPI PathIsUNCServerW(LPCWSTR lpszPath)
Definition: path.c:2302

Referenced by copy_file(), create_target_directory(), FILEDLG95_InitControls(), CFSFolder::GetCustomViewInfo(), getIconLocationForDrive(), getIconLocationForFolder(), CFileDefExt::Initialize(), LoadPropSheetHandlers(), PathIsDirectoryEmptyW(), ATL::CPathT< StringType >::PathIsDirectoryX(), SHELL_execute(), SHExplorerParseCmdLine(), and wWinMain().

◆ PathIsFileSpecA()

BOOL WINAPI PathIsFileSpecA ( LPCSTR  lpszPath)

Definition at line 2091 of file path.c.

2092 {
2093  TRACE("(%s)\n", debugstr_a(lpszPath));
2094 
2095  if (!lpszPath)
2096  return FALSE;
2097 
2098  while (*lpszPath)
2099  {
2100  if (*lpszPath == '\\' || *lpszPath == ':')
2101  return FALSE;
2102  lpszPath = CharNextA(lpszPath);
2103  }
2104  return TRUE;
2105 }
#define TRUE
Definition: types.h:120
LPSTR WINAPI CharNextA(_In_ LPCSTR)
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

Referenced by PathFindOnPathExA(), and ATL::CPathT< StringType >::PathIsFileSpecX().

◆ PathIsFileSpecW()

BOOL WINAPI PathIsFileSpecW ( LPCWSTR  lpszPath)

Definition at line 2112 of file path.c.

2113 {
2114  TRACE("(%s)\n", debugstr_w(lpszPath));
2115 
2116  if (!lpszPath)
2117  return FALSE;
2118 
2119  while (*lpszPath)
2120  {
2121  if (*lpszPath == '\\' || *lpszPath == ':')
2122  return FALSE;
2123  lpszPath++;
2124  }
2125  return TRUE;
2126 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by Control_LoadApplet(), PathFindOnPathExW(), and ATL::CPathT< StringType >::PathIsFileSpecX().

◆ PathIsLFNFileSpecA()

BOOL WINAPI PathIsLFNFileSpecA ( LPCSTR  lpszPath)

Definition at line 3801 of file path.c.

3802 {
3803  DWORD dwNameLen = 0, dwExtLen = 0;
3804 
3805  TRACE("(%s)\n",debugstr_a(lpszPath));
3806 
3807  if (!lpszPath)
3808  return FALSE;
3809 
3810  while (*lpszPath)
3811  {
3812  if (*lpszPath == ' ')
3813  return TRUE; /* DOS names cannot have spaces */
3814  if (*lpszPath == '.')
3815  {
3816  if (dwExtLen)
3817  return TRUE; /* DOS names have only one dot */
3818  dwExtLen = 1;
3819  }
3820  else if (dwExtLen)
3821  {
3822  dwExtLen++;
3823  if (dwExtLen > 4)
3824  return TRUE; /* DOS extensions are <= 3 chars*/
3825  }
3826  else
3827  {
3828  dwNameLen++;
3829  if (dwNameLen > 8)
3830  return TRUE; /* DOS names are <= 8 chars */
3831  }
3832  lpszPath += IsDBCSLeadByte(*lpszPath) ? 2 : 1;
3833  }
3834  return FALSE; /* Valid DOS path */
3835 }
#define TRUE
Definition: types.h:120
BOOL WINAPI IsDBCSLeadByte(BYTE TestByte)
Definition: nls.c:2221
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95

◆ PathIsLFNFileSpecW()

BOOL WINAPI PathIsLFNFileSpecW ( LPCWSTR  lpszPath)

Definition at line 3842 of file path.c.

3843 {
3844  DWORD dwNameLen = 0, dwExtLen = 0;
3845 
3846  TRACE("(%s)\n",debugstr_w(lpszPath));
3847 
3848  if (!lpszPath)
3849  return FALSE;
3850 
3851  while (*lpszPath)
3852  {
3853  if (*lpszPath == ' ')
3854  return TRUE; /* DOS names cannot have spaces */
3855  if (*lpszPath == '.')
3856  {
3857  if (dwExtLen)
3858  return TRUE; /* DOS names have only one dot */
3859  dwExtLen = 1;
3860  }
3861  else if (dwExtLen)
3862  {
3863  dwExtLen++;
3864  if (dwExtLen > 4)
3865  return TRUE; /* DOS extensions are <= 3 chars*/
3866  }
3867  else
3868  {
3869  dwNameLen++;
3870  if (dwNameLen > 8)
3871  return TRUE; /* DOS names are <= 8 chars */
3872  }
3873  lpszPath++;
3874  }
3875  return FALSE; /* Valid DOS path */
3876 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95

◆ PathIsNetworkPathA()

BOOL WINAPI PathIsNetworkPathA ( LPCSTR  lpszPath)

Definition at line 3742 of file path.c.

3743 {
3744  int dwDriveNum;
3745 
3746  TRACE("(%s)\n",debugstr_a(lpszPath));
3747 
3748  if (!lpszPath)
3749  return FALSE;
3750  if (*lpszPath == '\\' && lpszPath[1] == '\\')
3751  return TRUE;
3752  dwDriveNum = PathGetDriveNumberA(lpszPath);
3753  if (dwDriveNum == -1)
3754  return FALSE;
3755 #ifdef __REACTOS__
3756  return IsNetDrive(dwDriveNum);
3757 #else
3758  GET_FUNC(pIsNetDrive, shell32, (LPCSTR)66, FALSE); /* ord 66 = shell32.IsNetDrive */
3759  return pIsNetDrive(dwDriveNum);
3760 #endif
3761 }
#define TRUE
Definition: types.h:120
EXTERN_C int WINAPI IsNetDrive(int drive)
Definition: shlfileop.cpp:2001
static HANDLE shell32
Definition: animate.c:36
static fnpIsNetDrive pIsNetDrive
Definition: path.c:61
const char * LPCSTR
Definition: xmlstorage.h:183
#define GET_FUNC(func, module, name, fail)
Definition: path.c:47
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
int WINAPI PathGetDriveNumberA(LPCSTR lpszPath)
Definition: path.c:533

◆ PathIsNetworkPathW()

BOOL WINAPI PathIsNetworkPathW ( LPCWSTR  lpszPath)

Definition at line 3768 of file path.c.

3769 {
3770  int dwDriveNum;
3771 
3772  TRACE("(%s)\n", debugstr_w(lpszPath));
3773 
3774  if (!lpszPath)
3775  return FALSE;
3776  if (*lpszPath == '\\' && lpszPath[1] == '\\')
3777  return TRUE;
3778  dwDriveNum = PathGetDriveNumberW(lpszPath);
3779  if (dwDriveNum == -1)
3780  return FALSE;
3781 #ifdef __REACTOS__
3782  return IsNetDrive(dwDriveNum);
3783 #else
3784  GET_FUNC(pIsNetDrive, shell32, (LPCSTR)66, FALSE); /* ord 66 = shell32.IsNetDrive */
3785  return pIsNetDrive(dwDriveNum);
3786 #endif
3787 }
#define TRUE
Definition: types.h:120
EXTERN_C int WINAPI IsNetDrive(int drive)
Definition: shlfileop.cpp:2001
static HANDLE shell32
Definition: animate.c:36
#define debugstr_w
Definition: kernel32.h:32
static fnpIsNetDrive pIsNetDrive
Definition: path.c:61
const char * LPCSTR
Definition: xmlstorage.h:183
#define GET_FUNC(func, module, name, fail)
Definition: path.c:47
#define TRACE(s)
Definition: solgame.cpp:4
int WINAPI PathGetDriveNumberW(const WCHAR *path)
Definition: path.c:548

◆ PathIsPrefixA()

BOOL WINAPI PathIsPrefixA ( LPCSTR  lpszPrefix,
LPCSTR  lpszPath 
)

Definition at line 2141 of file path.c.

2142 {
2143  TRACE("(%s,%s)\n", debugstr_a(lpszPrefix), debugstr_a(lpszPath));
2144 
2145  if (lpszPrefix && lpszPath &&
2146  PathCommonPrefixA(lpszPath, lpszPrefix, NULL) == (int)strlen(lpszPrefix))
2147  return TRUE;
2148  return FALSE;
2149 }
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int WINAPI PathCommonPrefixA(LPCSTR lpszFile1, LPCSTR lpszFile2, LPSTR achPath)
Definition: path.c:2730
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

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

◆ PathIsPrefixW()

BOOL WINAPI PathIsPrefixW ( LPCWSTR  lpszPrefix,
LPCWSTR  lpszPath 
)

Definition at line 2156 of file path.c.

2157 {
2158  TRACE("(%s,%s)\n", debugstr_w(lpszPrefix), debugstr_w(lpszPath));
2159 
2160  if (lpszPrefix && lpszPath &&
2161  PathCommonPrefixW(lpszPath, lpszPrefix, NULL) == (int)strlenW(lpszPrefix))
2162  return TRUE;
2163  return FALSE;
2164 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPath)
Definition: path.c:2785
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4

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

◆ PathIsRelativeA()

BOOL WINAPI PathIsRelativeA ( LPCSTR  lpszPath)

Definition at line 1542 of file path.c.

1543 {
1544  TRACE("(%s)\n",debugstr_a(lpszPath));
1545 
1546  if (!lpszPath || !*lpszPath || IsDBCSLeadByte(*lpszPath))
1547  return TRUE;
1548  if (*lpszPath == '\\' || (*lpszPath && lpszPath[1] == ':'))
1549  return FALSE;
1550  return TRUE;
1551 }
#define TRUE
Definition: types.h:120
BOOL WINAPI IsDBCSLeadByte(BYTE TestByte)
Definition: nls.c:2221
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

Referenced by ATL::CPathT< StringType >::PathIsRelativeX(), and TestGetModuleFileNameA().

◆ PathIsRelativeW()

BOOL WINAPI PathIsRelativeW ( LPCWSTR  lpszPath)

Definition at line 1558 of file path.c.

1559 {
1560  TRACE("(%s)\n",debugstr_w(lpszPath));
1561 
1562  if (!lpszPath || !*lpszPath)
1563  return TRUE;
1564  if (*lpszPath == '\\' || (*lpszPath && lpszPath[1] == ':'))
1565  return FALSE;
1566  return TRUE;
1567 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by COMDLG32_GetCanonicalPath(), CFSFolder::GetCustomViewInfo(), getIconLocationForDrive(), getIconLocationForFolder(), msi_apply_transforms(), msi_dialog_verify_path(), MSI_OpenProductW(), OpenColorProfileW(), parse_file_list(), PathCombineW(), ATL::CPathT< StringType >::PathIsRelativeX(), SHCreateDirectoryExW(), SHGetFileInfoW(), and TestGetModuleFileNameW().

◆ PathIsRootA()

BOOL WINAPI PathIsRootA ( LPCSTR  lpszPath)

Definition at line 1581 of file path.c.

1582 {
1583  TRACE("(%s)\n", debugstr_a(lpszPath));
1584 
1585  if (lpszPath && *lpszPath)
1586  {
1587  if (*lpszPath == '\\')
1588  {
1589  if (!lpszPath[1])
1590  return TRUE; /* \ */
1591  else if (lpszPath[1]=='\\')
1592  {
1593  BOOL bSeenSlash = FALSE;
1594  lpszPath += 2;
1595 
1596  /* Check for UNC root path */
1597  while (*lpszPath)
1598  {
1599  if (*lpszPath == '\\')
1600  {
1601  if (bSeenSlash)
1602  return FALSE;
1603  bSeenSlash = TRUE;
1604  }
1605  lpszPath = CharNextA(lpszPath);
1606  }
1607  return TRUE;
1608  }
1609  }
1610  else if (lpszPath[1] == ':' && lpszPath[2] == '\\' && lpszPath[3] == '\0')
1611  return TRUE; /* X:\ */
1612  }
1613  return FALSE;
1614 }
#define TRUE
Definition: types.h:120
LPSTR WINAPI CharNextA(_In_ LPCSTR)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

Referenced by PathIsRootAW(), ATL::CPathT< StringType >::PathIsRootX(), PathRemoveBackslashA(), and PathStripToRootA().

◆ PathIsRootW()

BOOL WINAPI PathIsRootW ( LPCWSTR  lpszPath)

Definition at line 1621 of file path.c.

1622 {
1623  TRACE("(%s)\n", debugstr_w(lpszPath));
1624 
1625  if (lpszPath && *lpszPath)
1626  {
1627  if (*lpszPath == '\\')
1628  {
1629  if (!lpszPath[1])
1630  return TRUE; /* \ */
1631  else if (lpszPath[1]=='\\')
1632  {
1633  BOOL bSeenSlash = FALSE;
1634  lpszPath += 2;
1635 
1636  /* Check for UNC root path */
1637  while (*lpszPath)
1638  {
1639  if (*lpszPath == '\\')
1640  {
1641  if (bSeenSlash)
1642  return FALSE;
1643  bSeenSlash = TRUE;
1644  }
1645  lpszPath++;
1646  }
1647  return TRUE;
1648  }
1649  }
1650  else if (lpszPath[1] == ':' && lpszPath[2] == '\\' && lpszPath[3] == '\0')
1651  return TRUE; /* X:\ */
1652  }
1653  return FALSE;
1654 }
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by PathIsRootAW(), ATL::CPathT< StringType >::PathIsRootX(), PathRemoveBackslashW(), PathStripToRootW(), and SH_ShowPropertiesDialog().

◆ PathIsSameRootA()

BOOL WINAPI PathIsSameRootA ( LPCSTR  lpszPath1,
LPCSTR  lpszPath2 
)

Definition at line 1982 of file path.c.

1983 {
1984  LPCSTR lpszStart;
1985  int dwLen;
1986 
1987  TRACE("(%s,%s)\n", debugstr_a(lpszPath1), debugstr_a(lpszPath2));
1988 
1989  if (!lpszPath1 || !lpszPath2 || !(lpszStart = PathSkipRootA(lpszPath1)))
1990  return FALSE;
1991 
1992  dwLen = PathCommonPrefixA(lpszPath1, lpszPath2, NULL) + 1;
1993  if (lpszStart - lpszPath1 > dwLen)
1994  return FALSE; /* Paths not common up to length of the root */
1995  return TRUE;
1996 }
#define TRUE
Definition: types.h:120
int WINAPI PathCommonPrefixA(LPCSTR lpszFile1, LPCSTR lpszFile2, LPSTR achPath)
Definition: path.c:2730
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
LPSTR WINAPI PathSkipRootA(LPCSTR lpszPath)
Definition: path.c:3226
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

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

◆ PathIsSameRootW()

BOOL WINAPI PathIsSameRootW ( LPCWSTR  lpszPath1,
LPCWSTR  lpszPath2 
)

Definition at line 2003 of file path.c.

2004 {
2005  LPCWSTR lpszStart;
2006  int dwLen;
2007 
2008  TRACE("(%s,%s)\n", debugstr_w(lpszPath1), debugstr_w(lpszPath2));
2009 
2010  if (!lpszPath1 || !lpszPath2 || !(lpszStart = PathSkipRootW(lpszPath1)))
2011  return FALSE;
2012 
2013  dwLen = PathCommonPrefixW(lpszPath1, lpszPath2, NULL) + 1;
2014  if (lpszStart - lpszPath1 > dwLen)
2015  return FALSE; /* Paths not common up to length of the root */
2016  return TRUE;
2017 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPath)
Definition: path.c:2785
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR WINAPI PathSkipRootW(LPCWSTR lpszPath)
Definition: path.c:3257

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

◆ PathIsSystemFolderA()

BOOL WINAPI PathIsSystemFolderA ( LPCSTR  lpszPath,
DWORD  dwAttrib 
)

Definition at line 2179 of file path.c.

2180 {
2181  TRACE("(%s,0x%08x)\n", debugstr_a(lpszPath), dwAttrib);
2182 
2183  if (lpszPath && *lpszPath)
2184  dwAttrib = GetFileAttributesA(lpszPath);
2185 
2186  if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY) ||
2188  return FALSE;
2189  return TRUE;
2190 }
#define TRUE
Definition: types.h:120
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

◆ PathIsSystemFolderW()

BOOL WINAPI PathIsSystemFolderW ( LPCWSTR  lpszPath,
DWORD  dwAttrib 
)

Definition at line 2197 of file path.c.

2198 {
2199  TRACE("(%s,0x%08x)\n", debugstr_w(lpszPath), dwAttrib);
2200 
2201  if (lpszPath && *lpszPath)
2202  dwAttrib = GetFileAttributesW(lpszPath);
2203 
2204  if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY) ||
2206  return FALSE;
2207  return TRUE;
2208 }
#define TRUE
Definition: types.h:120
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define debugstr_w
Definition: kernel32.h:32
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define TRACE(s)
Definition: solgame.cpp:4
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

◆ PathIsUNCA()

BOOL WINAPI PathIsUNCA ( LPCSTR  lpszPath)

Definition at line 2222 of file path.c.

2223 {
2224  TRACE("(%s)\n",debugstr_a(lpszPath));
2225 
2226 /*
2227  * On Windows 2003, tests show that strings starting with "\\?" are
2228  * considered UNC, while on Windows Vista+ this is not the case anymore.
2229  */
2230 // #ifdef __REACTOS__
2231 #if (WINVER >= _WIN32_WINNT_VISTA)
2232  if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\') && (lpszPath[2]!='?'))
2233 #else
2234  if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'))
2235 #endif
2236  return TRUE;
2237  return FALSE;
2238 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

Referenced by PathAppendA(), PathCommonPrefixA(), and ATL::CPathT< StringType >::PathIsUNCX().

◆ PathIsUNCServerA()

BOOL WINAPI PathIsUNCServerA ( LPCSTR  lpszPath)

Definition at line 2280 of file path.c.

2281 {
2282  TRACE("(%s)\n", debugstr_a(lpszPath));
2283 
2284  if (lpszPath && *lpszPath++ == '\\' && *lpszPath++ == '\\')
2285  {
2286  while (*lpszPath)
2287  {
2288  if (*lpszPath == '\\')
2289  return FALSE;
2290  lpszPath = CharNextA(lpszPath);
2291  }
2292  return TRUE;
2293  }
2294  return FALSE;
2295 }
#define TRUE
Definition: types.h:120
LPSTR WINAPI CharNextA(_In_ LPCSTR)
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

Referenced by PathIsDirectoryA(), and ATL::CPathT< StringType >::PathIsUNCServerX().

◆ PathIsUNCServerShareA()

BOOL WINAPI PathIsUNCServerShareA ( LPCSTR  lpszPath)

Definition at line 2330 of file path.c.

2331 {
2332  TRACE("(%s)\n", debugstr_a(lpszPath));
2333 
2334  if (lpszPath && *lpszPath++ == '\\' && *lpszPath++ == '\\')
2335  {
2336  BOOL bSeenSlash = FALSE;
2337  while (*lpszPath)
2338  {
2339  if (*lpszPath == '\\')
2340  {
2341  if (bSeenSlash)
2342  return FALSE;
2343  bSeenSlash = TRUE;
2344  }
2345  lpszPath = CharNextA(lpszPath);
2346  }
2347  return bSeenSlash;
2348  }
2349  return FALSE;
2350 }
#define TRUE
Definition: types.h:120
LPSTR WINAPI CharNextA(_In_ LPCSTR)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31

Referenced by PathIsDirectoryA(), and ATL::CPathT< StringType >::PathIsUNCServerShareX().

◆ PathIsUNCServerShareW()

BOOL WINAPI PathIsUNCServerShareW ( LPCWSTR  lpszPath)

Definition at line 2357 of file path.c.

2358 {
2359  TRACE("(%s)\n", debugstr_w(lpszPath));
2360 
2361  if (lpszPath && *lpszPath++ == '\\' && *lpszPath++ == '\\')
2362  {
2363  BOOL bSeenSlash = FALSE;
2364  while (*lpszPath)
2365  {
2366  if (*lpszPath == '\\')
2367  {
2368  if (bSeenSlash)
2369  return FALSE;
2370  bSeenSlash = TRUE;
2371  }
2372  lpszPath++;
2373  }
2374  return bSeenSlash;
2375  }
2376  return FALSE;
2377 }
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by PathCanonicalizeW(), PathFileExistsDefExtW(), PathIsDirectoryW(), and ATL::CPathT< StringType >::PathIsUNCServerShareX().

◆ PathIsUNCServerW()

BOOL WINAPI PathIsUNCServerW ( LPCWSTR  lpszPath)

Definition at line 2302 of file path.c.

2303 {
2304  TRACE("(%s)\n", debugstr_w(lpszPath));
2305 
2306  if (lpszPath && lpszPath[0] == '\\' && lpszPath[1] == '\\')
2307  {
2308  return !strchrW( lpszPath + 2, '\\' );
2309  }
2310  return FALSE;
2311 }
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by PathFileExistsDefExtW(), PathIsDirectoryW(), and ATL::CPathT< StringType >::PathIsUNCServerX().

◆ PathIsUNCW()

BOOL WINAPI PathIsUNCW ( LPCWSTR  lpszPath)

Definition at line 2245 of file path.c.

2246 {
2247  TRACE("(%s)\n",debugstr_w(lpszPath));
2248 
2249 /*
2250  * On Windows 2003, tests show that strings starting with "\\?" are
2251  * considered UNC, while on Windows Vista+ this is not the case anymore.
2252  */
2253 // #ifdef __REACTOS__
2254 #if (WINVER >= _WIN32_WINNT_VISTA)
2255  if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\') && (lpszPath[2]!='?'))
2256 #else
2257  if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'))
2258 #endif
2259  return TRUE;
2260  return FALSE;
2261 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by CDesktopFolder::ParseDisplayName(), PathAppendW(), PathCombineW(), PathCommonPrefixW(), and ATL::CPathT< StringType >::PathIsUNCX().

◆ PathIsValidCharA()

BOOL WINAPI PathIsValidCharA ( char  c,
DWORD  class 
)

Definition at line 4383 of file path.c.

4384 {
4385  if ((unsigned)c > 0x7e)
4386  return class & PATH_CHAR_CLASS_OTHER_VALID;
4387 
4388  return class & SHELL_charclass[(unsigned)c];
4389 }
#define PATH_CHAR_CLASS_OTHER_VALID
Definition: path.c:4304
const GLubyte * c
Definition: glext.h:8905
static const DWORD SHELL_charclass[]
Definition: path.c:4310

◆ PathIsValidCharW()

BOOL WINAPI PathIsValidCharW ( WCHAR  c,
DWORD  class 
)

Definition at line 4396 of file path.c.

4397 {
4398  if (c > 0x7e)
4399  return class & PATH_CHAR_CLASS_OTHER_VALID;
4400 
4401  return class & SHELL_charclass[c];
4402 }
#define PATH_CHAR_CLASS_OTHER_VALID
Definition: path.c:4304
const GLubyte * c
Definition: glext.h:8905
static const DWORD SHELL_charclass[]
Definition: path.c:4310
#define c
Definition: ke_i.h:80

◆ PathMakePrettyA()

BOOL WINAPI PathMakePrettyA ( LPSTR  lpszPath)

Definition at line 2647 of file path.c.

2648 {
2649  LPSTR pszIter = lpszPath;
2650 
2651  TRACE("(%s)\n", debugstr_a(lpszPath));
2652 
2653  if (!pszIter)
2654  return FALSE;
2655 
2656  if (*pszIter)
2657  {
2658  do
2659  {
2660  if (islower(*pszIter) || IsDBCSLeadByte(*pszIter))
2661  return FALSE; /* Not DOS path */
2662  pszIter++;
2663  } while (*pszIter);
2664  pszIter = lpszPath + 1;
2665  while (*pszIter)
2666  {
2667  *pszIter = tolower(*pszIter);
2668  pszIter++;
2669  }
2670  }
2671  return TRUE;
2672 }
#define TRUE
Definition: types.h:120
char * LPSTR
Definition: xmlstorage.h:182
BOOL WINAPI IsDBCSLeadByte(BYTE TestByte)
Definition: nls.c:2221
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define islower(c)
Definition: acclib.h:72
int tolower(int c)
Definition: utclib.c:902

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

◆ PathMakePrettyW()

BOOL WINAPI PathMakePrettyW ( LPWSTR  lpszPath)

Definition at line 2679 of file path.c.

2680 {
2681  LPWSTR pszIter = lpszPath;
2682 
2683  TRACE("(%s)\n", debugstr_w(lpszPath));
2684 
2685  if (!pszIter)
2686  return FALSE;
2687 
2688  if (*pszIter)
2689  {
2690  do
2691  {
2692  if (islowerW(*pszIter))
2693  return FALSE; /* Not DOS path */
2694  pszIter++;
2695  } while (*pszIter);
2696  pszIter = lpszPath + 1;
2697  while (*pszIter)
2698  {
2699  *pszIter = tolowerW(*pszIter);
2700  pszIter++;
2701  }
2702  }
2703  return TRUE;
2704 }
WINE_UNICODE_INLINE int islowerW(WCHAR wc)
Definition: unicode.h:180
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
WINE_UNICODE_INLINE WCHAR tolowerW(WCHAR ch)
Definition: unicode.h:135
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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

◆ PathMakeSystemFolderA()

BOOL WINAPI PathMakeSystemFolderA ( LPCSTR  lpszPath)

Definition at line 3079 of file path.c.

3080 {
3081  BOOL bRet = FALSE;
3082 
3083  TRACE("(%s)\n", debugstr_a(lpszPath));
3084 
3085  if (lpszPath && *lpszPath)
3086  {
3088  MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
3089  bRet = PathMakeSystemFolderW(szPath);
3090  }
3091  return bRet;
3092 }
#define CP_ACP
Definition: compat.h:99
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
BOOL WINAPI PathMakeSystemFolderW(LPCWSTR lpszPath)
Definition: path.c:3099
#define MAX_PATH
Definition: compat.h:26
LPCWSTR szPath
Definition: env.c:35
#define MultiByteToWideChar
Definition: compat.h:100

◆ PathMakeSystemFolderW()

BOOL WINAPI PathMakeSystemFolderW ( LPCWSTR  lpszPath)

Definition at line 3099 of file path.c.

3100 {
3101  DWORD dwDefaultAttr = FILE_ATTRIBUTE_READONLY, dwAttr;
3102  WCHAR buff[MAX_PATH];
3103 
3104  TRACE("(%s)\n", debugstr_w(lpszPath));
3105 
3106  if (!lpszPath || !*lpszPath)
3107  return FALSE;
3108 
3109  /* If the directory is already a system directory, don't do anything */
3111  if (!strcmpW(buff, lpszPath))
3112  return TRUE;
3113 
3115  if (!strcmpW(buff, lpszPath))
3116  return TRUE;
3117 
3118  /* "UseSystemForSystemFolders" Tells Win what attributes to use */
3120  dwDefaultAttr = FILE_ATTRIBUTE_SYSTEM;
3121 
3122  if ((dwAttr = GetFileAttributesW(lpszPath)) == INVALID_FILE_ATTRIBUTES)
3123  return FALSE;
3124 
3125  /* Change file attributes to system attributes */
3127  return SetFileAttributesW(lpszPath, dwAttr | dwDefaultAttr);
3128 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
#define TRUE
Definition: types.h:120
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
static BOOL SHLWAPI_UseSystemForSystemFolders(void)
Definition: path.c:3049
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
static unsigned char buff[32768]
Definition: fatten.c:17

Referenced by PathMakeSystemFolderA().

◆ PathMatchSingleMaskA()

static BOOL PathMatchSingleMaskA ( LPCSTR  name,
LPCSTR  mask 
)
static

Definition at line 1832 of file path.c.

1833 {
1834  while (*name && *mask && *mask!=';')
1835  {
1836  if (*mask == '*')
1837  {
1838  do
1839  {
1841  return TRUE; /* try substrings */
1842  } while (*name++);
1843  return FALSE;
1844  }
1845 
1846  if (toupper(*mask) != toupper(*name) && *mask != '?')
1847  return FALSE;
1848 
1849  name = CharNextA(name);
1850  mask = CharNextA(mask);
1851  }
1852 
1853  if (!*name)
1854  {
1855  while (*mask == '*')
1856  mask++;
1857  if (!*mask || *mask == ';')
1858  return TRUE;
1859  }
1860  return FALSE;
1861 }
#define TRUE
Definition: types.h:120
LPSTR WINAPI CharNextA(_In_ LPCSTR)
GLenum GLint GLuint mask
Definition: glext.h:6028
int toupper(int c)
Definition: utclib.c:881
static BOOL PathMatchSingleMaskA(LPCSTR name, LPCSTR mask)
Definition: path.c:1832
Definition: name.c:36

Referenced by PathMatchSpecA().

◆ PathMatchSingleMaskW()

static BOOL PathMatchSingleMaskW ( LPCWSTR  name,
LPCWSTR  mask 
)
static

Definition at line 1866 of file path.c.

1867 {
1868  while (*name && *mask && *mask != ';')
1869  {
1870  if (*mask == '*')
1871  {
1872  do
1873  {
1875  return TRUE; /* try substrings */
1876  } while (*name++);
1877  return FALSE;
1878  }
1879 
1880  if (toupperW(*mask) != toupperW(*name) && *mask != '?')
1881  return FALSE;
1882 
1883  name++;
1884  mask++;
1885  }
1886  if (!*name)
1887  {
1888  while (*mask == '*')
1889  mask++;
1890  if (!*mask || *mask == ';')
1891  return TRUE;
1892  }
1893  return FALSE;
1894 }
#define TRUE
Definition: types.h:120
static BOOL PathMatchSingleMaskW(LPCWSTR name, LPCWSTR mask)
Definition: path.c:1866
GLenum GLint GLuint mask
Definition: glext.h:6028
WINE_UNICODE_INLINE WCHAR toupperW(WCHAR ch)
Definition: unicode.h:141
Definition: name.c:36

Referenced by PathMatchSpecW().

◆ PathMatchSpecA()

BOOL WINAPI PathMatchSpecA ( LPCSTR  lpszPath,
LPCSTR  lpszMask 
)

Definition at line 1914 of file path.c.

1915 {
1916  TRACE("(%s,%s)\n", lpszPath, lpszMask);
1917 
1918  if (!lstrcmpA(lpszMask, "*.*"))
1919  return TRUE; /* Matches every path */
1920 
1921  while (*lpszMask)
1922  {
1923  while (*lpszMask == ' ')
1924  lpszMask++; /* Eat leading spaces */
1925 
1926  if (PathMatchSingleMaskA(lpszPath, lpszMask))
1927  return TRUE; /* Matches the current mask */
1928 
1929  while (*lpszMask && *lpszMask != ';')
1930  lpszMask = CharNextA(lpszMask); /* masks separated by ';' */
1931 
1932  if (*lpszMask == ';')
1933  lpszMask++;
1934  }
1935  return FALSE;
1936 }
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
LPSTR WINAPI CharNextA(_In_ LPCSTR)
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL PathMatchSingleMaskA(LPCSTR name, LPCSTR mask)
Definition: path.c:1832

Referenced by ATL::CPathT< StringType >::PathMatchSpecX(), and test_PathMatchSpec().

◆ PathMatchSpecW()

BOOL WINAPI PathMatchSpecW ( LPCWSTR  lpszPath,
LPCWSTR  lpszMask 
)

Definition at line 1943 of file path.c.

1944 {
1945  static const WCHAR szStarDotStar[] = { '*', '.', '*', '\0' };
1946 
1947  TRACE("(%s,%s)\n", debugstr_w(lpszPath), debugstr_w(lpszMask));
1948 
1949  if (!lstrcmpW(lpszMask, szStarDotStar))
1950  return TRUE; /* Matches every path */
1951 
1952  while (*lpszMask)
1953  {
1954  while (*lpszMask == ' ')
1955  lpszMask++; /* Eat leading spaces */
1956 
1957  if (PathMatchSingleMaskW(lpszPath, lpszMask))
1958  return TRUE; /* Matches the current path */
1959 
1960  while (*lpszMask && *lpszMask != ';')
1961  lpszMask++; /* masks separated by ';' */
1962 
1963  if (*lpszMask == ';')
1964  lpszMask++;
1965  }
1966  return FALSE;
1967 }
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
static BOOL PathMatchSingleMaskW(LPCWSTR name, LPCWSTR mask)
Definition: path.c:1866
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by FTP_ParseNextFile(), ICommDlgBrowser3_fnIncludeObject(), IShellBrowserImpl_ICommDlgBrowser_IncludeObject(), on_command_filetype(), and ATL::CPathT< StringType >::PathMatchSpecX().

◆ PathParseIconLocationA()

int WINAPI PathParseIconLocationA ( LPSTR  lpszPath)

Definition at line 1062 of file path.c.

1063 {
1064  int iRet = 0;
1065  LPSTR lpszComma;
1066 
1067  TRACE("(%s)\n", debugstr_a(lpszPath));
1068 
1069  if (lpszPath)
1070  {
1071  if ((lpszComma = strchr(lpszPath, ',')))
1072  {
1073  *lpszComma++ = '\0';
1074  iRet = StrToIntA(lpszComma);
1075  }
1076  PathUnquoteSpacesA(lpszPath);
1077  PathRemoveBlanksA(lpszPath);
1078  }
1079  return iRet;
1080 }
VOID WINAPI PathRemoveBlanksA(LPSTR lpszPath)
Definition: path.c:889
char * LPSTR
Definition: xmlstorage.h:182
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
VOID WINAPI PathUnquoteSpacesA(LPSTR lpszPath)
Definition: path.c:1007
char * strchr(const char *String, int ch)
Definition: utclib.c:501
INT WINAPI StrToIntA(LPCSTR lpszStr)
Definition: string.c:374

◆ PathParseIconLocationW()

int WINAPI PathParseIconLocationW ( LPWSTR  lpszPath)

Definition at line 1087 of file path.c.

1088 {
1089  int iRet = 0;
1090  LPWSTR lpszComma;
1091 
1092  TRACE("(%s)\n", debugstr_w(lpszPath));
1093 
1094  if (lpszPath)
1095  {
1096  if ((lpszComma = StrChrW(lpszPath, ',')))
1097  {
1098  *lpszComma++ = '\0';
1099  iRet = StrToIntW(lpszComma);
1100  }
1101  PathUnquoteSpacesW(lpszPath);
1102  PathRemoveBlanksW(lpszPath);
1103  }
1104  return iRet;
1105 }
VOID WINAPI PathRemoveBlanksW(LPWSTR lpszPath)
Definition: path.c:915
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1029
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:468
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:411
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DoFileTypeIconLocation(), getIconLocationForDrive(), getIconLocationForFolder(), and CFileDefExt::InitFolderCustomizePage().

◆ PathQuoteSpacesA()

VOID WINAPI PathQuoteSpacesA ( LPSTR  lpszPath)

Definition at line 950 of file path.c.

951 {
952  TRACE("(%s)\n", debugstr_a(lpszPath));
953 
954  if(lpszPath && StrChrA(lpszPath,' '))
955  {
956  size_t iLen = strlen(lpszPath) + 1;
957 
958  if (iLen + 2 < MAX_PATH)
959  {
960  memmove(lpszPath + 1, lpszPath, iLen);
961  lpszPath[0] = '"';
962  lpszPath[iLen] = '"';
963  lpszPath[iLen + 1] = '\0';
964  }
965  }
966 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LPSTR WINAPI StrChrA(LPCSTR lpszStr, WORD ch)
Definition: string.c:270
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26

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

◆ PathQuoteSpacesW()

VOID WINAPI PathQuoteSpacesW ( LPWSTR  lpszPath)

Definition at line 973 of file path.c.

974 {
975  TRACE("(%s)\n", debugstr_w(lpszPath));
976 
977  if(lpszPath && StrChrW(lpszPath,' '))
978  {
979  int iLen = strlenW(lpszPath) + 1;
980 
981  if (iLen + 2 < MAX_PATH)
982  {
983  memmove(lpszPath + 1, lpszPath, iLen * sizeof(WCHAR));
984  lpszPath[0] = '"';
985  lpszPath[iLen] = '"';
986  lpszPath[iLen + 1] = '\0';
987  }
988  }
989 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:468

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

◆ PathRelativePathToA()

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

Definition at line 3525 of file path.c.

3527 {
3528  BOOL bRet = FALSE;
3529 
3530  TRACE("(%p,%s,0x%08x,%s,0x%08x)\n", lpszPath, debugstr_a(lpszFrom),
3531  dwAttrFrom, debugstr_a(lpszTo), dwAttrTo);
3532 
3533  if(lpszPath && lpszFrom && lpszTo)
3534  {
3537  WCHAR szTo[MAX_PATH];
3538  MultiByteToWideChar(CP_ACP,0,lpszFrom,-1,szFrom,MAX_PATH);
3539  MultiByteToWideChar(CP_ACP,0,lpszTo,-1,szTo,MAX_PATH);
3540  bRet = PathRelativePathToW(szPath,szFrom,dwAttrFrom,szTo,dwAttrTo);
3541  WideCharToMultiByte(CP_ACP,0,szPath,-1,lpszPath,MAX_PATH,0,0);
3542  }
3543  return bRet;
3544 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
static const WCHAR szFrom[]
Definition: http.c:100
BOOL WINAPI PathRelativePathToW(LPWSTR lpszPath, LPCWSTR lpszFrom, DWORD dwAttrFrom, LPCWSTR lpszTo, DWORD dwAttrTo)
Definition: path.c:3551
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:26
LPCWSTR szPath
Definition: env.c:35
#define MultiByteToWideChar
Definition: compat.h:100

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

◆ PathRelativePathToW()

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

Definition at line 3551 of file path.c.

3553 {
3554  static const WCHAR szPrevDirSlash[] = { '.', '.', '\\', '\0' };
3555  static const WCHAR szPrevDir[] = { '.', '.', '\0' };
3557  WCHAR szTo[MAX_PATH];
3558  DWORD dwLen;
3559 
3560  TRACE("(%p,%s,0x%08x,%s,0x%08x)\n", lpszPath, debugstr_w(lpszFrom),
3561  dwAttrFrom, debugstr_w(lpszTo), dwAttrTo);
3562 
3563  if(!lpszPath || !lpszFrom || !lpszTo)
3564  return FALSE;
3565 
3566  *lpszPath = '\0';
3567  lstrcpynW(szFrom, lpszFrom, MAX_PATH);
3568  lstrcpynW(szTo, lpszTo, MAX_PATH);
3569 
3570  if(!(dwAttrFrom & FILE_ATTRIBUTE_DIRECTORY))
3572  if(!(dwAttrTo & FILE_ATTRIBUTE_DIRECTORY))
3573  PathRemoveFileSpecW(szTo);
3574 
3575  /* Paths can only be relative if they have a common root */
3576  if(!(dwLen = PathCommonPrefixW(szFrom, szTo, 0)))
3577  return FALSE;
3578 
3579  /* Strip off lpszFrom components to the root, by adding "..\" */
3580  lpszFrom = szFrom + dwLen;
3581  if (!*lpszFrom)
3582  {
3583  lpszPath[0] = '.';
3584  lpszPath[1] = '\0';
3585  }
3586  if (*lpszFrom == '\\')
3587  lpszFrom++;
3588 
3589  while (*lpszFrom)
3590  {
3591  lpszFrom = PathFindNextComponentW(lpszFrom);
3592  strcatW(lpszPath, *lpszFrom ? szPrevDirSlash : szPrevDir);
3593  }
3594 
3595  /* From the root add the components of lpszTo */
3596  lpszTo += dwLen;
3597  /* We check lpszTo[-1] to avoid skipping end of string. See the notes for
3598  * this function.
3599  */
3600  if (*lpszTo && lpszTo[-1])
3601  {
3602  if (*lpszTo != '\\')
3603  lpszTo--;
3604  dwLen = strlenW(lpszPath);
3605  if (dwLen + strlenW(lpszTo) >= MAX_PATH)
3606  {
3607  *lpszPath = '\0';
3608  return FALSE;
3609  }
3610  strcpyW(lpszPath + dwLen, lpszTo);
3611  }
3612  return TRUE;
3613 }
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:624
#define TRUE
Definition: types.h:120
LPWSTR WINAPI PathFindNextComponentW(LPCWSTR lpszPath)
Definition: path.c:2558
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPath)
Definition: path.c:2785
static const WCHAR szFrom[]
Definition: http.c:100
#define lstrcpynW
Definition: compat.h:397
#define debugstr_w
Definition: kernel32.h:32
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242

Referenced by PathRelativePathToA(), and ATL::CPathT< StringType >::PathRelativePathToX().

◆ PathRemoveArgsA()

void WINAPI PathRemoveArgsA ( LPSTR  lpszPath)

Definition at line 751 of file path.c.

752 {
753  TRACE("(%s)\n",debugstr_a(lpszPath));
754 
755  if(lpszPath)
756  {
757  LPSTR lpszArgs = PathGetArgsA(lpszPath);
758  if (*lpszArgs)
759  lpszArgs[-1] = '\0';
760  else
761  {
762  LPSTR lpszLastChar = CharPrevA(lpszPath, lpszArgs);
763  if(*lpszLastChar == ' ')
764  *lpszLastChar = '\0';
765  }
766  }
767 }
char * LPSTR
Definition: xmlstorage.h:182
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LPSTR WINAPI CharPrevA(_In_ LPCSTR, _In_ LPCSTR)
LPSTR WINAPI PathGetArgsA(LPCSTR lpszPath)
Definition: path.c:476

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

◆ PathRemoveArgsW()

void WINAPI PathRemoveArgsW ( LPWSTR  lpszPath)

Definition at line 774 of file path.c.

775 {
776  TRACE("(%s)\n",debugstr_w(lpszPath));
777 
778  if(lpszPath)
779  {
780  LPWSTR lpszArgs = PathGetArgsW(lpszPath);
781  if (*lpszArgs || (lpszArgs > lpszPath && lpszArgs[-1] == ' '))
782  lpszArgs[-1] = '\0';
783  }
784 }
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR WINAPI PathGetArgsW(LPCWSTR lpszPath)
Definition: path.c:501
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CShellLink::OnNotify(), and ATL::CPathT< StringType >::PathRemoveArgsX().

◆ PathRemoveBackslashA()

LPSTR WINAPI PathRemoveBackslashA ( LPSTR  lpszPath)

Definition at line 842 of file path.c.

843 {
844  LPSTR szTemp = NULL;
845 
846  TRACE("(%s)\n", debugstr_a(lpszPath));
847 
848  if(lpszPath)
849  {
850  szTemp = CharPrevA(lpszPath, lpszPath + strlen(lpszPath));
851  if (!PathIsRootA(lpszPath) && *szTemp == '\\')
852  *szTemp = '\0';
853  }
854  return szTemp;
855 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * LPSTR
Definition: xmlstorage.h:182
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LPSTR WINAPI CharPrevA(_In_ LPCSTR, _In_ LPCSTR)
BOOL WINAPI PathIsRootA(LPCSTR lpszPath)
Definition: path.c:1581

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

◆ PathRemoveBackslashW()

LPWSTR WINAPI PathRemoveBackslashW ( LPWSTR  lpszPath)

Definition at line 862 of file path.c.

863 {
864  LPWSTR szTemp = NULL;
865 
866  TRACE("(%s)\n", debugstr_w(lpszPath));
867 
868  if(lpszPath)
869  {
870  szTemp = lpszPath + strlenW(lpszPath);
871  if (szTemp > lpszPath) szTemp--;
872  if (!PathIsRootW(lpszPath) && *szTemp == '\\')
873  *szTemp = '\0';
874  }
875  return szTemp;
876 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1621
#define TRACE(s)
Definition: solgame.cpp:4