ReactOS 0.4.15-dev-7918-g2a2556c
RtlDosPathNameToNtPathName_U.c File Reference
#include "precomp.h"
Include dependency graph for RtlDosPathNameToNtPathName_U.c:

Go to the source code of this file.

Classes

struct  DirComponents
 

Macros

#define COMPILE_AS_ROSTEST
 
#define PREP0   /* The normal Win32 namespace. Fully parsed. */
 
#define PREP1   "\\\\.\\" /* The Win32 Device Namespace. Only partially parsed. */
 
#define PREP2   "\\\\?\\" /* The Win32 File Namespace. Only partially parsed. */
 

Typedefs

typedef struct DirComponents DirComponents
 

Functions

static void check_result (BOOLEAN bOK, const char *pszErr)
 
static void test2 (LPCWSTR pwsz, LPCWSTR pwszExpected, LPCWSTR pwszExpectedPartName)
 
static void test (const char *psz, const char *pszExpected, const char *pszExpectedPartName)
 
static void InitDirComponents (DirComponents *p)
 
 test (PREP1 "C:", "C:", "C:")
 
 test (PREP2 "C:", "C:", "C:")
 
 test (PREP0 "C:\\", "C:\\", NULL)
 
 test (PREP1 "C:\\", "C:\\", NULL)
 
 test (PREP2 "C:\\", "C:\\", NULL)
 
 test (PREP0 "C:\\foo", "C:\\foo", "foo")
 
 test (PREP1 "C:\\foo", "C:\\foo", "foo")
 
 test (PREP2 "C:\\foo", "C:\\foo", "foo")
 
 test (PREP0 "C:\\foo\\", "C:\\foo\\", NULL)
 
 test (PREP1 "C:\\foo\\", "C:\\foo\\", NULL)
 
 test (PREP2 "C:\\foo\\", "C:\\foo\\", NULL)
 
 test (PREP0 "C:\\foo\\bar", "C:\\foo\\bar", "bar")
 
 test (PREP1 "C:\\foo\\bar", "C:\\foo\\bar", "bar")
 
 test (PREP2 "C:\\foo\\bar", "C:\\foo\\bar", "bar")
 
 test (PREP0 "C:\\foo\\bar\\", "C:\\foo\\bar\\", NULL)
 
 test (PREP1 "C:\\foo\\bar\\", "C:\\foo\\bar\\", NULL)
 
 test (PREP2 "C:\\foo\\bar\\", "C:\\foo\\bar\\", NULL)
 
 test (PREP0 "C:\\foo\\..", "C:\\", NULL)
 
 test (PREP1 "C:\\foo\\..", "C:", "C:")
 
 test (PREP2 "C:\\foo\\..", "C:\\foo\\..", "..")
 
 test (PREP0 "C:\\foo\\..\\", "C:\\", NULL)
 
 test (PREP1 "C:\\foo\\..\\", "C:\\", NULL)
 
 test (PREP2 "C:\\foo\\..\\", "C:\\foo\\..\\", NULL)
 
 test (PREP0 "C:\\foo.", "C:\\foo", "foo")
 
 test (PREP1 "C:\\foo.", "C:\\foo", "foo")
 
 test (PREP2 "C:\\foo.", "C:\\foo.", "foo.")
 
 test (PREP0 "C:\\f\\b\\..", "C:\\f", "f")
 
 test (PREP1 "C:\\f\\b\\..", "C:\\f", "f")
 
 test (PREP2 "C:\\f\\b\\..", "C:\\f\\b\\..", "..")
 
 test (PREP0 "C:\\f\\b\\..\\", "C:\\f\\", NULL)
 
 test (PREP1 "C:\\f\\b\\..\\", "C:\\f\\", NULL)
 
 test (PREP2 "C:\\f\\b\\..\\", "C:\\f\\b\\..\\", NULL)
 
 sprintf (szTmp, "%s%s", cd.szCDPlusSlash, "foo")
 
 test (PREP0 "foo", szTmp, "foo")
 
 test (PREP1 "foo", "foo", "foo")
 
 test (PREP2 "foo", "foo", "foo")
 
 sprintf (szTmp, "%s%s", cd.szCDPlusSlash, "foo\\")
 
 test (PREP0 "foo\\", szTmp, NULL)
 
 test (PREP1 "foo\\", "foo\\", NULL)
 
 test (PREP2 "foo\\", "foo\\", NULL)
 
 test (PREP0 ".", cd.szCD, cd.pszLastCDComponent)
 
 test (PREP1 ".", "", NULL)
 
 test (PREP2 ".", ".", ".")
 
 test (PREP0 ".\\", cd.szCDPlusSlash, NULL)
 
 test (PREP1 ".\\", "", NULL)
 
 test (PREP2 ".\\", ".\\", NULL)
 
 test (PREP0 ".\\.", cd.szCD, cd.pszLastCDComponent)
 
 test (PREP1 ".\\.", "", NULL)
 
 test (PREP2 ".\\.", ".\\.", ".")
 
 test (PREP0 ".\\..", cd.pszPD, cd.pszNextLastCDComponent)
 
 test (PREP1 ".\\..", "", NULL)
 
 test (PREP2 ".\\..", ".\\..", "..")
 
 test (PREP0 "..", cd.pszPD, cd.pszNextLastCDComponent)
 
 test (PREP1 "..", "", NULL)
 
 test (PREP2 "..", "..", "..")
 
 test (PREP0 "..\\", cd.pszPDPlusSlash, NULL)
 
 test (PREP1 "..\\", "", NULL)
 
 test (PREP2 "..\\", "..\\", NULL)
 
 test (PREP0 "...", cd.szCDPlusSlash, NULL)
 
 test (PREP1 "...", "", NULL)
 
 test (PREP2 "...", "...", "...")
 
 test (PREP0 "NUL", "NUL", NULL)
 
 test (PREP1 "NUL", "NUL", "NUL")
 
 test (PREP2 "NUL", "NUL", "NUL")
 
 test (PREP0 "NUL:", "NUL", NULL)
 
 test (PREP1 "NUL:", "NUL:", "NUL:")
 
 test (PREP2 "NUL:", "NUL:", "NUL:")
 
 test (PREP0 "CON", "CON", NULL)
 
 test (PREP2 "CON", "CON", "CON")
 
 test (PREP0 "CON:", "CON", NULL)
 
 test (PREP1 "CON:", "CON:", "CON:")
 
 test (PREP2 "CON:", "CON:", "CON:")
 
 sprintf (szTmp, "%s\\%s", cd.szCD, "NUL:\\")
 
 test (PREP0 "NUL:\\", szTmp, NULL)
 
 test (PREP1 "NUL:\\", "NUL:\\", NULL)
 
 test (PREP2 "NUL:\\", "NUL:\\", NULL)
 
 test (PREP0 "C:NUL", "NUL", NULL)
 
 test (PREP1 "C:NUL", "C:NUL", "C:NUL")
 
 test (PREP2 "C:NUL", "C:NUL", "C:NUL")
 
 test (PREP0 "C:\\NUL", "NUL", NULL)
 
 test (PREP1 "C:\\NUL", "C:\\NUL", "NUL")
 
 test (PREP2 "C:\\NUL", "C:\\NUL", "NUL")
 
 test (PREP0 "C:\\NUL\\", "C:\\NUL\\", NULL)
 
 test (PREP1 "C:\\NUL\\", "C:\\NUL\\", NULL)
 
 test (PREP2 "C:\\NUL\\", "C:\\NUL\\", NULL)
 
 test (PREP0 "\\", cd.szCurDriveSlash, NULL)
 
 test (PREP1 "\\", "", NULL)
 
 test (PREP2 "\\", "\\", NULL)
 
 test (PREP0 "\\.", cd.szCurDriveSlash, NULL)
 
 test (PREP1 "\\.", "", NULL)
 
 test (PREP2 "\\.", "\\.", ".")
 
 test (PREP0 "\\..", cd.szCurDriveSlash, NULL)
 
 test (PREP1 "\\..", "", NULL)
 
 test (PREP2 "\\..", "\\..", "..")
 
 test (PREP0 "\\...", cd.szCurDriveSlash, NULL)
 
 test (PREP1 "\\...", "", NULL)
 
 test (PREP2 "\\...", "\\...", "...")
 
 sprintf (szTmp, "%s%s", cd.szCurDrive, "\\C:")
 
 test (PREP0 "\\C:", szTmp, "C:")
 
 test (PREP1 "\\C:", "C:", "C:")
 
 test (PREP2 "\\C:", "\\C:", "C:")
 
 sprintf (szTmp, "%s%s", cd.szCurDrive, "\\C:\\")
 
 test (PREP0 "\\C:\\", szTmp, NULL)
 
 test (PREP1 "\\C:\\", "C:\\", NULL)
 
 test (PREP2 "\\C:\\", "\\C:\\", NULL)
 
 test (PREP0 "\\\\", "UNC\\", NULL)
 
 test (PREP1 "\\\\", "", NULL)
 
 test (PREP2 "\\\\", "\\\\", NULL)
 
 test (PREP0 "\\\\\\", "UNC\\\\", NULL)
 
 test (PREP1 "\\\\\\", "", NULL)
 
 test (PREP2 "\\\\\\", "\\\\\\", NULL)
 
 test (PREP0 "\\\\foo", "UNC\\foo", NULL)
 
 test (PREP1 "\\\\foo", "foo", "foo")
 
 test (PREP2 "\\\\foo", "\\\\foo", "foo")
 
 test (PREP0 "\\\\foo\\..", "UNC\\foo\\", NULL)
 
 test (PREP1 "\\\\foo\\..", "", NULL)
 
 test (PREP2 "\\\\foo\\..", "\\\\foo\\..", "..")
 
 test (PREP0 "\\\\foo\\", "UNC\\foo\\", NULL)
 
 test (PREP1 "\\\\foo\\", "foo\\", NULL)
 
 test (PREP2 "\\\\foo\\", "\\\\foo\\", NULL)
 
 test (PREP0 "\\\\f\\b", "UNC\\f\\b", NULL)
 
 test (PREP1 "\\\\f\\b", "f\\b", "b")
 
 test (PREP2 "\\\\f\\b", "\\\\f\\b", "b")
 
 test (PREP0 "\\\\f\\b\\", "UNC\\f\\b\\", NULL)
 
 test (PREP1 "\\\\f\\b\\", "f\\b\\", NULL)
 
 test (PREP2 "\\\\f\\b\\", "\\\\f\\b\\", NULL)
 
 test (PREP0 "\\\\f\\b\\..", "UNC\\f\\b", NULL)
 
 test (PREP1 "\\\\f\\b\\..", "f", "f")
 
 test (PREP2 "\\\\f\\b\\..", "\\\\f\\b\\..", "..")
 
 test (PREP0 "\\\\C:", "UNC\\C:", NULL)
 
 test (PREP1 "\\\\C:", "C:", "C:")
 
 test (PREP2 "\\\\C:", "\\\\C:", "C:")
 
 test (PREP0 "\\\\C:\\", "UNC\\C:\\", NULL)
 
 test (PREP1 "\\\\C:\\", "C:\\", NULL)
 
 test (PREP2 "\\\\C:\\", "\\\\C:\\", NULL)
 
 test (PREP0 "\\\\NUL", "UNC\\NUL", NULL)
 
 test (PREP1 "\\\\NUL", "NUL", "NUL")
 
 test (PREP2 "\\\\NUL", "\\\\NUL", "NUL")
 
 test (PREP0 "\\\\NUL:", "UNC\\NUL:", NULL)
 
 test (PREP1 "\\\\NUL:", "NUL:", "NUL:")
 
 test (PREP2 "\\\\NUL:", "\\\\NUL:", "NUL:")
 
 test (PREP0 "\\\\NUL:\\", "UNC\\NUL:\\", NULL)
 
 test (PREP1 "\\\\NUL:\\", "NUL:\\", NULL)
 
 test (PREP2 "\\\\NUL:\\", "\\\\NUL:\\", NULL)
 
 test (PREP0 "//", "UNC\\", NULL)
 
 test (PREP1 "//", "", NULL)
 
 test (PREP2 "//", "//", "//")
 
 test (PREP0 "//C:", "UNC\\C:", NULL)
 
 test (PREP1 "//C:", "C:", "C:")
 
 test (PREP2 "//C:", "//C:", "//C:")
 
 test (PREP0 "//C:/", "UNC\\C:\\", NULL)
 
 test (PREP1 "//C:/", "C:\\", NULL)
 
 test (PREP2 "//C:/", "//C:/", "//C:/")
 
 test (PREP0 "//.", "", NULL)
 
 test (PREP1 "//.", "", NULL)
 
 test (PREP2 "//.", "//.", "//.")
 
 test (PREP0 "//..", "UNC\\", NULL)
 
 test (PREP1 "//..", "", NULL)
 
 test (PREP2 "//..", "//..", "//..")
 
 test (PREP0 "/./", cd.szCurDriveSlash, NULL)
 
 test (PREP1 "/./", "", NULL)
 
 test (PREP2 "/./", "/./", "/./")
 
 test (PREP0 "//./", "", NULL)
 
 test (PREP1 "//./", "", NULL)
 
 test (PREP2 "//./", "//./", "//./")
 
 test (cd.szCD, cd.szCD, cd.pszLastCDComponent)
 
 test (cd.szCDPlusSlash, cd.szCDPlusSlash, NULL)
 

Variables

char szTmp [518]
 
InitDirComponentscd
 

Macro Definition Documentation

◆ COMPILE_AS_ROSTEST

#define COMPILE_AS_ROSTEST

Definition at line 34 of file RtlDosPathNameToNtPathName_U.c.

◆ PREP0

#define PREP0   /* The normal Win32 namespace. Fully parsed. */

Definition at line 366 of file RtlDosPathNameToNtPathName_U.c.

◆ PREP1

#define PREP1   "\\\\.\\" /* The Win32 Device Namespace. Only partially parsed. */

Definition at line 367 of file RtlDosPathNameToNtPathName_U.c.

◆ PREP2

#define PREP2   "\\\\?\\" /* The Win32 File Namespace. Only partially parsed. */

Definition at line 368 of file RtlDosPathNameToNtPathName_U.c.

Typedef Documentation

◆ DirComponents

Function Documentation

◆ check_result()

static void check_result ( BOOLEAN  bOK,
const char pszErr 
)
static

Definition at line 81 of file RtlDosPathNameToNtPathName_U.c.

82{
83#ifdef COMPILE_AS_ROSTEST
84 ok(bOK, "%s.\n", pszErr);
85#else
86 if (!bOK) {
87 printf("\a** %s.\n", pszErr);
88 }
89#endif
90}
#define ok(value,...)
Definition: atltest.h:57
#define printf
Definition: freeldr.h:93

Referenced by InitDirComponents(), and test2().

◆ InitDirComponents()

static void InitDirComponents ( DirComponents p)
static

Definition at line 222 of file RtlDosPathNameToNtPathName_U.c.

223{
224 /* While the following code seems to work, it's an unholy mess
225 * and should probably be cleaned up.
226 */
227 BOOLEAN bOK;
228
229 p->pszNextLastCDComponent = 0;
230 p->pszPD = 0;
231 p->pszPDPlusSlash = 0;
232
233 GetCurrentDirectory(sizeof(p->szCD) / sizeof(*p->szCD), p->szCD);
234
235 bOK = strlen(p->szCD) >= 2 && p->szCD[1] == ':';
236 check_result(bOK, "Expected curdir to be a drive letter. It's not");
237
238 if (!bOK) {
239 printf("Curdir is \"%s\"\n", p->szCD);
240 exit(1);
241 }
242
243 bOK = p->szCD[2] == '\\';
244 check_result(bOK, "CD is missing a slash as its third character");
245 if (!bOK) {
246 printf("CD is \"%s\"\n", p->szCD);
247 exit(1);
248 }
249
250 // Note that if executed from the root directory, a backslash is
251 // already appended.
252 strcpy(p->szCDPlusSlash, p->szCD);
253 if (strlen(p->szCD) > 3) {
254 // Append trailing backslash
255 strcat(p->szCDPlusSlash, "\\");
256 }
257
258 memcpy(p->szCurDrive, p->szCD, 2);
259 p->szCurDrive[2] = 0;
260 sprintf(p->szCurDriveSlash, "%s\\", p->szCurDrive);
261
262 p->pszLastCDComponent = strrchr(p->szCD, '\\');
263 if (p->pszLastCDComponent)
264 {
265 // We have a parent directory
266 memcpy(p->szParentDir, p->szCD, p->pszLastCDComponent - p->szCD);
267 p->szParentDir[p->pszLastCDComponent - p->szCD] = 0;
268 p->pszPD = p->szParentDir;
269 if (strlen(p->szParentDir) == 2 && p->szParentDir[1] == ':') {
270 // When run from root directory, this is expected to
271 // have a trailing backslash
272 strcat(p->szParentDir, "\\");
273 }
274 strcpy(p->szParentDirPlusSlash, p->szParentDir);
275 if (p->szParentDirPlusSlash[strlen(p->szParentDirPlusSlash)-1] != '\\') {
276 strcat(p->szParentDirPlusSlash, "\\");
277 }
278 p->pszPDPlusSlash = p->szParentDirPlusSlash;
279
280 // Check if we have a directory above that too.
281 *p->pszLastCDComponent = 0;
282 p->pszNextLastCDComponent = strrchr(p->szCD, '\\');
283 *p->pszLastCDComponent = '\\';
284 if (p->pszNextLastCDComponent) {
285 ++p->pszNextLastCDComponent; // skip the leading slash
286 if (p->pszNextLastCDComponent + 1 >= p->pszLastCDComponent) {
287 p->pszNextLastCDComponent = 0;
288 } else {
289 const size_t siz = p->pszLastCDComponent - p->pszNextLastCDComponent;
290 memcpy(p->szNextLastCDComponent, p->pszNextLastCDComponent, siz);
291 p->szNextLastCDComponent[siz] = 0;
292 p->pszNextLastCDComponent = p->szNextLastCDComponent;
293 }
294 }
295 }
296 if (p->pszLastCDComponent && p->pszLastCDComponent[1] == 0) {
297 // If the backslash is the last character in the path,
298 // this is a NULL-component.
299 p->pszLastCDComponent = 0;
300 } else {
301 ++p->pszLastCDComponent; // skip the leading slash
302 }
303}
unsigned char BOOLEAN
static void check_result(BOOLEAN bOK, const char *pszErr)
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLfloat GLfloat p
Definition: glext.h:8902
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define sprintf(buf, format,...)
Definition: sprintf.c:55
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define exit(n)
Definition: config.h:202
#define GetCurrentDirectory
Definition: winbase.h:3805

◆ sprintf() [1/5]

sprintf ( szTmp  ,
"%s%s"  ,
cd.  szCDPlusSlash,
"foo"   
)

◆ sprintf() [2/5]

sprintf ( szTmp  ,
"%s%s"  ,
cd.  szCDPlusSlash,
"foo\\"   
)

◆ sprintf() [3/5]

sprintf ( szTmp  ,
"%s%s"  ,
cd.  szCurDrive,
"\\C:"   
)

◆ sprintf() [4/5]

sprintf ( szTmp  ,
"%s%s"  ,
cd.  szCurDrive,
"\\C:\\"   
)

◆ sprintf() [5/5]

sprintf ( szTmp  ,
"%s\\%s"  ,
cd.  szCD,
"NUL:\\"   
)

◆ test() [1/163]

test ( cd.  szCD,
cd.  szCD,
cd.  pszLastCDComponent 
)

◆ test() [2/163]

test ( cd.  szCDPlusSlash,
cd.  szCDPlusSlash,
NULL   
)

◆ test() [3/163]

static void test ( const char psz,
const char pszExpected,
const char pszExpectedPartName 
)
static

Definition at line 185 of file RtlDosPathNameToNtPathName_U.c.

186{
187 WCHAR wszTmp1[512];
188 WCHAR wszTmp2[512];
189 WCHAR wszTmp3[512];
190 LPCWSTR p2 = 0;
191 LPCWSTR p3 = 0;
192 swprintf(wszTmp1, L"%S", psz);
193 if (pszExpected) {
194 swprintf(wszTmp2, L"%S", pszExpected);
195 p2 = wszTmp2;
196 }
197 if (pszExpectedPartName) {
198 swprintf(wszTmp3, L"%S", pszExpectedPartName);
199 p3 = wszTmp3;
200 }
201 test2(wszTmp1, p2, p3);
202}
#define swprintf
Definition: precomp.h:40
void test2()
Definition: ehthrow.cxx:284
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ test() [4/163]

test ( PREP0 "."  ,
cd.  szCD,
cd.  pszLastCDComponent 
)

◆ test() [5/163]

test ( PREP0 ".."  ,
cd.  pszPD,
cd.  pszNextLastCDComponent 
)

◆ test() [6/163]

test ( PREP0 "..."  ,
cd.  szCDPlusSlash,
NULL   
)

◆ test() [7/163]

test ( PREP0 "..\\"  ,
cd.  pszPDPlusSlash,
NULL   
)

◆ test() [8/163]

test ( PREP0 ".\\"  ,
cd.  szCDPlusSlash,
NULL   
)

◆ test() [9/163]

test ( PREP0 ".\\."  ,
cd.  szCD,
cd.  pszLastCDComponent 
)

◆ test() [10/163]

test ( PREP0 ".\\.."  ,
cd.  pszPD,
cd.  pszNextLastCDComponent 
)

◆ test() [11/163]

test ( PREP0 "/./"  ,
cd.  szCurDriveSlash,
NULL   
)

◆ test() [12/163]

test ( PREP0 "//"  ,
"UNC\\"  ,
NULL   
)

◆ test() [13/163]

test ( PREP0 "//."  ,
""  ,
NULL   
)

◆ test() [14/163]

test ( PREP0 "//.."  ,
"UNC\\"  ,
NULL   
)

◆ test() [15/163]

test ( PREP0 "//./"  ,
""  ,
NULL   
)

◆ test() [16/163]

test ( PREP0 "//C:"  ,
"UNC\\C:"  ,
NULL   
)

◆ test() [17/163]

test ( PREP0 "//C:/"  ,
"UNC\\C:\\"  ,
NULL   
)

◆ test() [18/163]

test ( PREP0 "\\"  ,
cd.  szCurDriveSlash,
NULL   
)

◆ test() [19/163]

test ( PREP0 "\\."  ,
cd.  szCurDriveSlash,
NULL   
)

◆ test() [20/163]

test ( PREP0 "\\.."  ,
cd.  szCurDriveSlash,
NULL   
)

◆ test() [21/163]

test ( PREP0 "\\..."  ,
cd.  szCurDriveSlash,
NULL   
)

◆ test() [22/163]

test ( PREP0 "\\\\"  ,
"UNC\\"  ,
NULL   
)

◆ test() [23/163]

test ( PREP0 "\\\\\\"  ,
"UNC\\\\"  ,
NULL   
)

◆ test() [24/163]

test ( PREP0 "\\\\C:"  ,
"UNC\\C:"  ,
NULL   
)

◆ test() [25/163]

test ( PREP0 "\\\\C:\\"  ,
"UNC\\C:\\"  ,
NULL   
)

◆ test() [26/163]

test ( PREP0 "\\\\f\\b"  ,
"UNC\\f\\b"  ,
NULL   
)

◆ test() [27/163]

test ( PREP0 "\\\\f\\b\\"  ,
"UNC\\f\\b\\"  ,
NULL   
)

◆ test() [28/163]

test ( PREP0 "\\\\f\\b\\.."  ,
"UNC\\f\\b"  ,
NULL   
)

◆ test() [29/163]

test ( PREP0 "\\\\foo"  ,
"UNC\\foo"  ,
NULL   
)

◆ test() [30/163]

test ( PREP0 "\\\\foo\\"  ,
"UNC\\foo\\"  ,
NULL   
)

◆ test() [31/163]

test ( PREP0 "\\\\foo\\.."  ,
"UNC\\foo\\"  ,
NULL   
)

◆ test() [32/163]

test ( PREP0 "\\\\NUL"  ,
"UNC\\NUL"  ,
NULL   
)

◆ test() [33/163]

test ( PREP0 "\\\\NUL:"  ,
"UNC\\NUL:"  ,
NULL   
)

◆ test() [34/163]

test ( PREP0 "\\\\NUL:\\"  ,
"UNC\\NUL:\\"  ,
NULL   
)

◆ test() [35/163]

test ( PREP0 "\\C:"  ,
szTmp  ,
"C:"   
)

◆ test() [36/163]

test ( PREP0 "\\C:\\"  ,
szTmp  ,
NULL   
)

◆ test() [37/163]

test ( PREP0 "C:\\"  ,
"C:\\"  ,
NULL   
)

◆ test() [38/163]

test ( PREP0 "C:\\f\\b\\.."  ,
"C:\\f"  ,
"f"   
)

◆ test() [39/163]

test ( PREP0 "C:\\f\\b\\..\\"  ,
"C:\\f\\"  ,
NULL   
)

◆ test() [40/163]

test ( PREP0 "C:\\foo"  ,
"C:\\foo"  ,
"foo"   
)

◆ test() [41/163]

test ( PREP0 "C:\\foo."  ,
"C:\\foo"  ,
"foo"   
)

◆ test() [42/163]

test ( PREP0 "C:\\foo\\"  ,
"C:\\foo\\"  ,
NULL   
)

◆ test() [43/163]

test ( PREP0 "C:\\foo\\.."  ,
"C:\\"  ,
NULL   
)

◆ test() [44/163]

test ( PREP0 "C:\\foo\\..\\"  ,
"C:\\"  ,
NULL   
)

◆ test() [45/163]

test ( PREP0 "C:\\foo\\bar"  ,
"C:\\foo\\bar"  ,
"bar"   
)

◆ test() [46/163]

test ( PREP0 "C:\\foo\\bar\\"  ,
"C:\\foo\\bar\\"  ,
NULL   
)

◆ test() [47/163]

test ( PREP0 "C:\\NUL"  ,
"NUL"  ,
NULL   
)

◆ test() [48/163]

test ( PREP0 "C:\\NUL\\"  ,
"C:\\NUL\\"  ,
NULL   
)

◆ test() [49/163]

test ( PREP0 "C:NUL"  ,
"NUL"  ,
NULL   
)

◆ test() [50/163]

test ( PREP0 "CON"  ,
"CON"  ,
NULL   
)

◆ test() [51/163]

test ( PREP0 "CON:"  ,
"CON"  ,
NULL   
)

◆ test() [52/163]

test ( PREP0 "foo"  ,
szTmp  ,
"foo"   
)

◆ test() [53/163]

test ( PREP0 "foo\\"  ,
szTmp  ,
NULL   
)

◆ test() [54/163]

test ( PREP0 "NUL"  ,
"NUL"  ,
NULL   
)

◆ test() [55/163]

test ( PREP0 "NUL:"  ,
"NUL"  ,
NULL   
)

◆ test() [56/163]

test ( PREP0 "NUL:\\"  ,
szTmp  ,
NULL   
)

◆ test() [57/163]

test ( PREP1 "."  ,
""  ,
NULL   
)

◆ test() [58/163]

test ( PREP1 ".."  ,
""  ,
NULL   
)

◆ test() [59/163]

test ( PREP1 "..."  ,
""  ,
NULL   
)

◆ test() [60/163]

test ( PREP1 "..\\"  ,
""  ,
NULL   
)

◆ test() [61/163]

test ( PREP1 ".\\"  ,
""  ,
NULL   
)

◆ test() [62/163]

test ( PREP1 ".\\."  ,
""  ,
NULL   
)

◆ test() [63/163]

test ( PREP1 ".\\.."  ,
""  ,
NULL   
)

◆ test() [64/163]

test ( PREP1 "/./"  ,
""  ,
NULL   
)

◆ test() [65/163]

test ( PREP1 "//"  ,
""  ,
NULL   
)

◆ test() [66/163]

test ( PREP1 "//."  ,
""  ,
NULL   
)

◆ test() [67/163]

test ( PREP1 "//.."  ,
""  ,
NULL   
)

◆ test() [68/163]

test ( PREP1 "//./"  ,
""  ,
NULL   
)

◆ test() [69/163]

test ( PREP1 "//C:"  ,
"C:"  ,
"C:"   
)

◆ test() [70/163]

test ( PREP1 "//C:/"  ,
"C:\\"  ,
NULL   
)

◆ test() [71/163]

test ( PREP1 "\\"  ,
""  ,
NULL   
)

◆ test() [72/163]

test ( PREP1 "\\."  ,
""  ,
NULL   
)

◆ test() [73/163]

test ( PREP1 "\\.."  ,
""  ,
NULL   
)

◆ test() [74/163]

test ( PREP1 "\\..."  ,
""  ,
NULL   
)

◆ test() [75/163]

test ( PREP1 "\\\\"  ,
""  ,
NULL   
)

◆ test() [76/163]

test ( PREP1 "\\\\\\"  ,
""  ,
NULL   
)

◆ test() [77/163]

test ( PREP1 "\\\\C:"  ,
"C:"  ,
"C:"   
)

◆ test() [78/163]

test ( PREP1 "\\\\C:\\"  ,
"C:\\"  ,
NULL   
)

◆ test() [79/163]

test ( PREP1 "\\\\f\\b"  ,
"f\\b"  ,
"b"   
)

◆ test() [80/163]

test ( PREP1 "\\\\f\\b\\"  ,
"f\\b\\"  ,
NULL   
)

◆ test() [81/163]

test ( PREP1 "\\\\f\\b\\.."  ,
"f"  ,
"f"   
)

◆ test() [82/163]

test ( PREP1 "\\\\foo"  ,
"foo"  ,
"foo"   
)

◆ test() [83/163]

test ( PREP1 "\\\\foo\\"  ,
"foo\\"  ,
NULL   
)

◆ test() [84/163]

test ( PREP1 "\\\\foo\\.."  ,
""  ,
NULL   
)

◆ test() [85/163]

test ( PREP1 "\\\\NUL"  ,
"NUL"  ,
"NUL"   
)

◆ test() [86/163]

test ( PREP1 "\\\\NUL:"  ,
"NUL:"  ,
"NUL:"   
)

◆ test() [87/163]

test ( PREP1 "\\\\NUL:\\"  ,
"NUL:\\"  ,
NULL   
)

◆ test() [88/163]

test ( PREP1 "\\C:"  ,
"C:"  ,
"C:"   
)

◆ test() [89/163]

test ( PREP1 "\\C:\\"  ,
"C:\\"  ,
NULL   
)

◆ test() [90/163]

test ( PREP1 "C:"  ,
"C:"  ,
"C:"   
)

◆ test() [91/163]

test ( PREP1 "C:\\"  ,
"C:\\"  ,
NULL   
)

◆ test() [92/163]

test ( PREP1 "C:\\f\\b\\.."  ,
"C:\\f"  ,
"f"   
)

◆ test() [93/163]

test ( PREP1 "C:\\f\\b\\..\\"  ,
"C:\\f\\"  ,
NULL   
)

◆ test() [94/163]

test ( PREP1 "C:\\foo"  ,
"C:\\foo"  ,
"foo"   
)

◆ test() [95/163]

test ( PREP1 "C:\\foo."  ,
"C:\\foo"  ,
"foo"   
)

◆ test() [96/163]

test ( PREP1 "C:\\foo\\"  ,
"C:\\foo\\"  ,
NULL   
)

◆ test() [97/163]

test ( PREP1 "C:\\foo\\.."  ,
"C:"  ,
"C:"   
)

◆ test() [98/163]

test ( PREP1 "C:\\foo\\..\\"  ,
"C:\\"  ,
NULL   
)

◆ test() [99/163]

test ( PREP1 "C:\\foo\\bar"  ,
"C:\\foo\\bar"  ,
"bar"   
)

◆ test() [100/163]

test ( PREP1 "C:\\foo\\bar\\"  ,
"C:\\foo\\bar\\"  ,
NULL   
)

◆ test() [101/163]

test ( PREP1 "C:\\NUL"  ,
"C:\\NUL"  ,
"NUL"   
)

◆ test() [102/163]

test ( PREP1 "C:\\NUL\\"  ,
"C:\\NUL\\"  ,
NULL   
)

◆ test() [103/163]

test ( PREP1 "C:NUL"  ,
"C:NUL"  ,
"C:NUL"   
)

◆ test() [104/163]

test ( PREP1 "CON:"  ,
"CON:"  ,
"CON:"   
)

◆ test() [105/163]

test ( PREP1 "foo"  ,
"foo"  ,
"foo"   
)

◆ test() [106/163]

test ( PREP1 "foo\\"  ,
"foo\\"  ,
NULL   
)

◆ test() [107/163]

test ( PREP1 "NUL"  ,
"NUL"  ,
"NUL"   
)

◆ test() [108/163]

test ( PREP1 "NUL:"  ,
"NUL:"  ,
"NUL:"   
)

◆ test() [109/163]

test ( PREP1 "NUL:\\"  ,
"NUL:\\"  ,
NULL   
)

◆ test() [110/163]

test ( PREP2 "."  ,
"."  ,
"."   
)

◆ test() [111/163]

test ( PREP2 ".."  ,
".."  ,
".."   
)

◆ test() [112/163]

test ( PREP2 "..."  ,
"..."  ,
"..."   
)

◆ test() [113/163]

test ( PREP2 "..\\"  ,
"..\\"  ,
NULL   
)

◆ test() [114/163]

test ( PREP2 ".\\"  ,
".\\"  ,
NULL   
)

◆ test() [115/163]

test ( PREP2 ".\\."  ,
".\\."  ,
"."   
)

◆ test() [116/163]

test ( PREP2 ".\\.."  ,
".\\.."  ,
".."   
)

◆ test() [117/163]

test ( PREP2 "/./"  ,
"/./"  ,
"/./"   
)

◆ test() [118/163]

test ( PREP2 "//"  ,
"//"  ,
"//"   
)

◆ test() [119/163]

test ( PREP2 "//."  ,
"//."  ,
"//."   
)

◆ test() [120/163]

test ( PREP2 "//.."  ,
"//.."  ,
"//.."   
)

◆ test() [121/163]

test ( PREP2 "//./"  ,
"//./"  ,
"//./"   
)

◆ test() [122/163]

test ( PREP2 "//C:"  ,
"//C:"  ,
"//C:"   
)

◆ test() [123/163]

test ( PREP2 "//C:/"  ,
"//C:/"  ,
"//C:/"   
)

◆ test() [124/163]

test ( PREP2 "\\"  ,
"\\"  ,
NULL   
)

◆ test() [125/163]

test ( PREP2 "\\."  ,
"\\."  ,
"."   
)

◆ test() [126/163]

test ( PREP2 "\\.."  ,
"\\.."  ,
".."   
)

◆ test() [127/163]

test ( PREP2 "\\..."  ,
"\\..."  ,
"..."   
)

◆ test() [128/163]

test ( PREP2 "\\\\"  ,
"\\\\"  ,
NULL   
)

◆ test() [129/163]

test ( PREP2 "\\\\\\"  ,
"\\\\\\"  ,
NULL   
)

◆ test() [130/163]

test ( PREP2 "\\\\C:"  ,
"\\\\C:"  ,
"C:"   
)

◆ test() [131/163]

test ( PREP2 "\\\\C:\\"  ,
"\\\\C:\\"  ,
NULL   
)

◆ test() [132/163]

test ( PREP2 "\\\\f\\b"  ,
"\\\\f\\b"  ,
"b"   
)

◆ test() [133/163]

test ( PREP2 "\\\\f\\b\\"  ,
"\\\\f\\b\\"  ,
NULL   
)

◆ test() [134/163]

test ( PREP2 "\\\\f\\b\\.."  ,
"\\\\f\\b\\.."  ,
".."   
)

◆ test() [135/163]

test ( PREP2 "\\\\foo"  ,
"\\\\foo"  ,
"foo"   
)

◆ test() [136/163]

test ( PREP2 "\\\\foo\\"  ,
"\\\\foo\\"  ,
NULL   
)

◆ test() [137/163]

test ( PREP2 "\\\\foo\\.."  ,
"\\\\foo\\.."  ,
".."   
)

◆ test() [138/163]

test ( PREP2 "\\\\NUL"  ,
"\\\\NUL"  ,
"NUL"   
)

◆ test() [139/163]

test ( PREP2 "\\\\NUL:"  ,
"\\\\NUL:"  ,
"NUL:"   
)

◆ test() [140/163]

test ( PREP2 "\\\\NUL:\\"  ,
"\\\\NUL:\\"  ,
NULL   
)

◆ test() [141/163]

test ( PREP2 "\\C:"  ,
"\\C:"  ,
"C:"   
)

◆ test() [142/163]

test ( PREP2 "\\C:\\"  ,
"\\C:\\"  ,
NULL   
)

◆ test() [143/163]

test ( PREP2 "C:"  ,
"C:"  ,
"C:"   
)

◆ test() [144/163]

test ( PREP2 "C:\\"  ,
"C:\\"  ,
NULL   
)

◆ test() [145/163]

test ( PREP2 "C:\\f\\b\\.."  ,
"C:\\f\\b\\.."  ,
".."   
)

◆ test() [146/163]

test ( PREP2 "C:\\f\\b\\..\\"  ,
"C:\\f\\b\\..\\"  ,
NULL   
)

◆ test() [147/163]

test ( PREP2 "C:\\foo"  ,
"C:\\foo"  ,
"foo"   
)

◆ test() [148/163]

test ( PREP2 "C:\\foo."  ,
"C:\\foo."  ,
"foo."   
)

◆ test() [149/163]

test ( PREP2 "C:\\foo\\"  ,
"C:\\foo\\"  ,
NULL   
)

◆ test() [150/163]

test ( PREP2 "C:\\foo\\.."  ,
"C:\\foo\\.."  ,
".."   
)

◆ test() [151/163]

test ( PREP2 "C:\\foo\\..\\"  ,
"C:\\foo\\..\\"  ,
NULL   
)

◆ test() [152/163]

test ( PREP2 "C:\\foo\\bar"  ,
"C:\\foo\\bar"  ,
"bar"   
)

◆ test() [153/163]

test ( PREP2 "C:\\foo\\bar\\"  ,
"C:\\foo\\bar\\"  ,
NULL   
)

◆ test() [154/163]

test ( PREP2 "C:\\NUL"  ,
"C:\\NUL"  ,
"NUL"   
)

◆ test() [155/163]

test ( PREP2 "C:\\NUL\\"  ,
"C:\\NUL\\"  ,
NULL   
)

◆ test() [156/163]

test ( PREP2 "C:NUL"  ,
"C:NUL"  ,
"C:NUL"   
)

◆ test() [157/163]

test ( PREP2 "CON"  ,
"CON"  ,
"CON"   
)

◆ test() [158/163]

test ( PREP2 "CON:"  ,
"CON:"  ,
"CON:"   
)

◆ test() [159/163]

test ( PREP2 "foo"  ,
"foo"  ,
"foo"   
)

◆ test() [160/163]

test ( PREP2 "foo\\"  ,
"foo\\"  ,
NULL   
)

◆ test() [161/163]

test ( PREP2 "NUL"  ,
"NUL"  ,
"NUL"   
)

◆ test() [162/163]

test ( PREP2 "NUL:"  ,
"NUL:"  ,
"NUL:"   
)

◆ test() [163/163]

test ( PREP2 "NUL:\\"  ,
"NUL:\\"  ,
NULL   
)

◆ test2()

static void test2 ( LPCWSTR  pwsz,
LPCWSTR  pwszExpected,
LPCWSTR  pwszExpectedPartName 
)
static

Definition at line 108 of file RtlDosPathNameToNtPathName_U.c.

109{
110 UNICODE_STRING NtName;
111 PWSTR PartName;
112 RTL_RELATIVE_NAME_U RelativeName;
113 BOOLEAN bOK;
114
115 bOK = RtlDosPathNameToNtPathName_U(pwsz, &NtName, (PCWSTR*)&PartName, &RelativeName);
116
117 check_result(bOK, "RtlDosPathNameToNtPathName_U failed");
118 if (!bOK) {
119 printf("input: \"%S\"\n", pwsz);
120 return;
121 }
122
123#if !defined(COMPILE_AS_ROSTEST) && defined(PRINT_INFO)
124 printf("--------------------------\n");
125 printf("in : \"%S\"\n", pwsz);
126 prucs("NtName", &NtName);
127 printf("PartName : \"%S\"\n", PartName ? PartName : L"(null)");
128// prucs("RelativeName", &RelativeName.RelativeName);
129#endif
130
131 // Disregarding input, output (NtName) shall always start with "\??\".
132 bOK = NtName.Length >= 8 &&
133 memcmp(NtName.Buffer, L"\\??\\", 8) == 0;
134 check_result(bOK, "NtName does not start with \"\\??\\\"");
135 if (!bOK) {
136 return;
137 }
138
139 if (pwszExpected) {
140 PWSTR pwszActual = NtName.Buffer + 4;
141 const size_t lenExp = wcslen(pwszExpected);
142 const size_t lenAct = (NtName.Length - 8) / 2;
143 bOK = (lenExp == lenAct) &&
144 memcmp(pwszActual, pwszExpected, lenExp * 2) == 0;
145 check_result(bOK, "NtName does not match expected");
146 if (!bOK)
147 {
148 printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz);
149 printf("Expected: %2Iu chars \"%S\"\n", lenExp, pwszExpected);
150 printf("Actual : %2Iu chars \"%S\"\n", lenAct, lenAct ? pwszActual : L"(null)");
151 return;
152 }
153 } else
154 if (NtName.Length)
155 {
156 PWSTR pwszActual = NtName.Buffer + 4;
157 const size_t lenAct = (NtName.Length - 8) / 2;
158 check_result(FALSE, "Unexpected NtName (expected NULL)");
159 printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz);
160 printf("Actual : %2Iu chars \"%S\"\n", lenAct, pwszActual);
161 }
162
163 if (pwszExpectedPartName) {
164 const size_t lenExp = wcslen(pwszExpectedPartName);
165 const size_t lenAct = PartName ? wcslen(PartName) : 0;
166 bOK = (lenExp == lenAct) &&
167 wcscmp(PartName, pwszExpectedPartName) == 0;
168 check_result(bOK, "PartName does not match expected");
169 if (!bOK) {
170 printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz);
171 printf("Expected: %2Iu chars \"%S\"\n", lenExp, pwszExpectedPartName);
172 printf("Actual : %2Iu chars \"%S\"\n", lenAct, lenAct ? PartName : L"(null)");
173 return;
174 }
175 } else
176 if (PartName)
177 {
178 check_result(FALSE, "Unexpected PartName (expected NULL).");
179 printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz);
180 printf("Actual : %2Iu chars %S\n", wcslen(PartName), PartName);
181 }
182}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define FALSE
Definition: types.h:117
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57

Variable Documentation

◆ cd

◆ szTmp

char szTmp[518]