FreeRDP/winpr/libwinpr/path/test/TestPathCchStripPrefix.c

62 lines
1.5 KiB
C
Raw Normal View History

2012-10-02 00:49:34 +04:00
#include <stdio.h>
#include <winpr/crt.h>
#include <winpr/path.h>
#include <winpr/tchar.h>
#include <winpr/winpr.h>
/**
* Naming Files, Paths, and Namespaces:
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247/
*/
static const TCHAR testPathPrefixFileNamespace[] = _T("\\\\?\\C:\\Program Files\\");
static const TCHAR testPathNoPrefixFileNamespace[] = _T("C:\\Program Files\\");
static const TCHAR testPathPrefixDeviceNamespace[] = _T("\\\\?\\GLOBALROOT");
int TestPathCchStripPrefix(int argc, char* argv[])
{
HRESULT status;
TCHAR Path[PATHCCH_MAX_CCH];
/* Path with prefix (File Namespace) */
_tcscpy(Path, testPathPrefixFileNamespace);
status = PathCchStripPrefix(Path, sizeof(testPathPrefixFileNamespace) / sizeof(TCHAR));
if (status != S_OK)
{
_tprintf(_T("PathCchStripPrefix status: 0x%08lX\n"), status);
2012-10-02 00:49:34 +04:00
return -1;
}
if (_tcscmp(Path, testPathNoPrefixFileNamespace) != 0)
{
_tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathNoPrefixFileNamespace);
return -1;
}
/* Path with prefix (Device Namespace) */
_tcscpy(Path, testPathPrefixDeviceNamespace);
status = PathCchStripPrefix(Path, sizeof(testPathPrefixDeviceNamespace) / sizeof(TCHAR));
if (status != S_FALSE)
{
_tprintf(_T("PathCchStripPrefix status: 0x%08lX\n"), status);
2012-10-02 00:49:34 +04:00
return -1;
}
if (_tcscmp(Path, testPathPrefixDeviceNamespace) != 0)
{
_tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathPrefixDeviceNamespace);
return -1;
}
return 0;
}