* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "precomp.h"
+#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"
+#define NO_SHLWAPI_STREAM
+#include "shlwapi.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(shell);
+
+#ifdef __REACTOS__
+int WINAPI IsNetDrive(int drive);
+#else
/* Get a function pointer from a DLL handle */
#define GET_FUNC(func, module, name, fail) \
typedef BOOL (WINAPI *fnpIsNetDrive)(int);
static fnpIsNetDrive pIsNetDrive;
+#endif /* __REACTOS__ */
+
+
HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR,LPWSTR,DWORD);
static inline WCHAR* heap_strdupAtoW(LPCSTR str)
*
* See PathGetDriveNumberA.
*/
-int WINAPI PathGetDriveNumberW(LPCWSTR lpszPath)
+int WINAPI PathGetDriveNumberW(const WCHAR *path)
{
- TRACE ("(%s)\n",debugstr_w(lpszPath));
+ WCHAR drive;
- if (lpszPath)
- {
- WCHAR tl = tolowerW(lpszPath[0]);
- if (tl >= 'a' && tl <= 'z' && lpszPath[1] == ':')
- return tl - 'a';
- }
- return -1;
+ static const WCHAR nt_prefixW[] = {'\\','\\','?','\\'};
+
+ TRACE("(%s)\n", debugstr_w(path));
+
+ if (!path)
+ return -1;
+
+ if (!strncmpW(path, nt_prefixW, 4))
+ path += 4;
+
+ drive = tolowerW(path[0]);
+ if (drive < 'a' || drive > 'z' || path[1] != ':')
+ return -1;
+
+ return drive - 'a';
}
/*************************************************************************
if (lpszPath)
{
LPSTR lpszFileName = PathFindFileNameA(lpszPath);
- if(lpszFileName)
+ if(lpszFileName != lpszPath)
RtlMoveMemory(lpszPath, lpszFileName, strlen(lpszFileName)+1);
}
}
TRACE("(%s)\n", debugstr_w(lpszPath));
lpszFileName = PathFindFileNameW(lpszPath);
- if(lpszFileName)
+ if(lpszFileName != lpszPath)
RtlMoveMemory(lpszPath, lpszFileName, (strlenW(lpszFileName)+1)*sizeof(WCHAR));
}
{
TRACE("(%s)\n",debugstr_a(lpszPath));
+/*
+ * On Windows 2003, tests show that strings starting with "\\?" are
+ * considered UNC, while on Windows Vista+ this is not the case anymore.
+ */
+// #ifdef __REACTOS__
+#if (WINVER >= _WIN32_WINNT_VISTA)
if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\') && (lpszPath[2]!='?'))
+#else
+ if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'))
+#endif
return TRUE;
return FALSE;
}
{
TRACE("(%s)\n",debugstr_w(lpszPath));
+/*
+ * On Windows 2003, tests show that strings starting with "\\?" are
+ * considered UNC, while on Windows Vista+ this is not the case anymore.
+ */
+// #ifdef __REACTOS__
+#if (WINVER >= _WIN32_WINNT_VISTA)
if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\') && (lpszPath[2]!='?'))
+#else
+ if (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'))
+#endif
return TRUE;
return FALSE;
}
if (!pszUrl || !pszPath || !pcchPath || !*pcchPath)
return E_INVALIDARG;
+ if (lstrlenW(pszUrl) < 5)
+ return E_INVALIDARG;
+
if (CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pszUrl, 5,
file_colon, 5) != CSTR_EQUAL)
return E_INVALIDARG;
src -= 1;
break;
case 2:
- if (CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, src, 9,
- localhost, 9) == CSTR_EQUAL &&
- (src[9] == '/' || src[9] == '\\'))
+ if (lstrlenW(src) >= 10 && CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE,
+ src, 9, localhost, 9) == CSTR_EQUAL && (src[9] == '/' || src[9] == '\\'))
{
/* 'file://localhost/' + escaped DOS path */
src += 10;
dwDriveNum = PathGetDriveNumberA(lpszPath);
if (dwDriveNum == -1)
return FALSE;
+#ifdef __REACTOS__
+ return IsNetDrive(dwDriveNum);
+#else
GET_FUNC(pIsNetDrive, shell32, (LPCSTR)66, FALSE); /* ord 66 = shell32.IsNetDrive */
return pIsNetDrive(dwDriveNum);
+#endif
}
/*************************************************************************
dwDriveNum = PathGetDriveNumberW(lpszPath);
if (dwDriveNum == -1)
return FALSE;
+#ifdef __REACTOS__
+ return IsNetDrive(dwDriveNum);
+#else
GET_FUNC(pIsNetDrive, shell32, (LPCSTR)66, FALSE); /* ord 66 = shell32.IsNetDrive */
return pIsNetDrive(dwDriveNum);
+#endif
}
/*************************************************************************
WCHAR szSearch[MAX_PATH];
DWORD dwLen;
HANDLE hfind;
- BOOL retVal = FALSE;
+ BOOL retVal = TRUE;
WIN32_FIND_DATAW find_data;
TRACE("(%s)\n",debugstr_w(lpszPath));
if (!lpszPath || !PathIsDirectoryW(lpszPath))
- return FALSE;
+ return FALSE;
lstrcpynW(szSearch, lpszPath, MAX_PATH);
PathAddBackslashW(szSearch);
strcpyW(szSearch + dwLen, szAllFiles);
hfind = FindFirstFileW(szSearch, &find_data);
- if (hfind != INVALID_HANDLE_VALUE)
+ if (hfind == INVALID_HANDLE_VALUE)
+ return FALSE;
+
+ do
{
- if (find_data.cFileName[0] == '.' && find_data.cFileName[1] == '.')
- /* The only directory entry should be the parent */
- retVal = !FindNextFileW(hfind, &find_data);
- FindClose(hfind);
+ if (find_data.cFileName[0] == '.')
+ {
+ if (find_data.cFileName[1] == '\0') continue;
+ if (find_data.cFileName[1] == '.' && find_data.cFileName[2] == '\0') continue;
+ }
+
+ retVal = FALSE;
+ break;
}
+ while (FindNextFileW(hfind, &find_data));
+ FindClose(hfind);
return retVal;
}
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 computernameW[] = {'%','C','O','M','P','U','T','E','R','N','A','M','E','%',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};
struct envvars_map envvars[] = {
{ allusersprofileW, sizeof(allusersprofileW)/sizeof(WCHAR) },
{ appdataW, sizeof(appdataW)/sizeof(WCHAR) },
- { computernameW, sizeof(computernameW)/sizeof(WCHAR) },
{ programfilesW, sizeof(programfilesW)/sizeof(WCHAR) },
{ systemrootW, sizeof(systemrootW)/sizeof(WCHAR) },
{ systemdriveW, sizeof(systemdriveW)/sizeof(WCHAR) },