From ed325359311febd7307850d971f7d846c0952aa5 Mon Sep 17 00:00:00 2001 From: Rolf Kalbermatter Date: Mon, 19 Jan 2004 21:46:14 +0000 Subject: [PATCH] Implemented PathFileExistsAndAttributesA/W function. --- dlls/shlwapi/path.c | 57 +++++++++++++++++++++++++++++++++++++++ dlls/shlwapi/shlwapi.spec | 4 +-- include/shlwapi.h | 4 +++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index 92b2843330d..51d97b040c1 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -1713,6 +1713,63 @@ BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath) return dwAttr == INVALID_FILE_ATTRIBUTES ? FALSE : TRUE; } +/************************************************************************* + * PathFileExistsAndAttributesA [SHLWAPI.445] + * + * Determine if a file exists. + * + * PARAMS + * lpszPath [I] Path to check + * dwAttr [O] attributes of file + * + * RETURNS + * TRUE If the file exists and is readable + * FALSE Otherwise + */ +BOOL WINAPI PathFileExistsAndAttributesA(LPCSTR lpszPath, DWORD *dwAttr) +{ + UINT iPrevErrMode; + DWORD dwVal = 0; + + TRACE("(%s %p)\n", debugstr_a(lpszPath), dwAttr); + + if (dwAttr) + *dwAttr = INVALID_FILE_ATTRIBUTES; + + if (!lpszPath) + return FALSE; + + iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS); + dwVal = GetFileAttributesA(lpszPath); + SetErrorMode(iPrevErrMode); + if (dwAttr) + *dwAttr = dwVal; + return (dwVal != INVALID_FILE_ATTRIBUTES); +} + +/************************************************************************* + * PathFileExistsAndAttributesW [SHLWAPI.446] + * + * See PathFileExistsA. + */ +BOOL WINAPI PathFileExistsAndAttributesW(LPCWSTR lpszPath, DWORD *dwAttr) +{ + UINT iPrevErrMode; + DWORD dwVal; + + TRACE("(%s %p)\n", debugstr_w(lpszPath), dwAttr); + + if (!lpszPath) + return FALSE; + + iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS); + dwVal = GetFileAttributesW(lpszPath); + SetErrorMode(iPrevErrMode); + if (dwAttr) + *dwAttr = dwVal; + return (dwVal != INVALID_FILE_ATTRIBUTES); +} + /************************************************************************* * PathMatchSingleMaskA [internal] */ diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec index 5334c4782de..639ac5ff56c 100644 --- a/dlls/shlwapi/shlwapi.spec +++ b/dlls/shlwapi/shlwapi.spec @@ -442,8 +442,8 @@ 442 stdcall @(wstr ptr long) kernel32.GetEnvironmentVariableW 443 stdcall @(ptr long) kernel32.GetSystemWindowsDirectoryA 444 stdcall @(ptr long) kernel32.GetSystemWindowsDirectoryW -445 stub -noname PathFileExistsAndAttributesA -446 stub -noname PathFileExistsAndAttributesW +445 stdcall -noname PathFileExistsAndAttributesA(str ptr) +446 stdcall -noname PathFileExistsAndAttributesW(wstr ptr) 447 stub -noname FixSlashesAndColonA 448 stub -noname FixSlashesAndColonW 449 stub -noname NextPathA diff --git a/include/shlwapi.h b/include/shlwapi.h index 47078652ddf..b46e9e6cde5 100644 --- a/include/shlwapi.h +++ b/include/shlwapi.h @@ -332,6 +332,10 @@ BOOL WINAPI PathFileExistsA(LPCSTR); BOOL WINAPI PathFileExistsW(LPCWSTR); #define PathFileExists WINELIB_NAME_AW(PathFileExists) +BOOL WINAPI PathFileExistsAndAttributesA(LPCSTR lpszPath, DWORD *dwAttr); +BOOL WINAPI PathFileExistsAndAttributesW(LPCWSTR lpszPath, DWORD *dwAttr); +#define PathFileExistsAndAttributes WINELIB_NAME_AW(PathFileExistsAndAttributes) + LPSTR WINAPI PathFindExtensionA(LPCSTR); LPWSTR WINAPI PathFindExtensionW(LPCWSTR); #define PathFindExtension WINELIB_NAME_AW(PathFindExtension)