ReactOS 0.4.15-dev-8241-g63935f8
splitpath.c File Reference
#include <apitest.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <stdarg.h>
Include dependency graph for splitpath.c:

Go to the source code of this file.

Functions

 START_TEST (splitpath)
 

Function Documentation

◆ START_TEST()

START_TEST ( splitpath  )

Definition at line 15 of file splitpath.c.

16{
17 char drive[5];
18 char dir[64];
19 char fname[32];
20 char ext[10];
21 DWORD Major;
22
23 Major = (DWORD)(LOBYTE(LOWORD(GetVersion())));
24
25 drive[2] = 0xFF;
26 _splitpath("c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext);
27 ok_str(drive, "c:");
28 ok_str(dir, "\\dir1\\dir2\\");
29 ok_str(fname, "file");
30 ok_str(ext, ".ext");
31 ok_int(drive[2], 0);
32
33 *_errno() = 0;
34 _splitpath("c:\\dir1\\dir2\\file.ext", 0, 0, 0, 0);
35 ok_int(*_errno(), 0);
36
37 if (Major >= 6)
38 {
39 *_errno() = 0;
40 _splitpath(0, drive, dir, fname, ext);
41 ok_int(*_errno(), EINVAL);
42 ok_str(drive, "");
43 ok_str(dir, "");
44 ok_str(fname, "");
45 ok_str(ext, "");
46 }
47 else
48 {
49 win_skip("This test only succeed on NT6+\n");
50 }
51
52 _splitpath("\\\\?\\c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext);
53 if (Major >= 6)
54 {
55 ok_str(drive, "c:");
56 ok_str(dir, "\\dir1\\dir2\\");
57 }
58 else
59 {
60 ok_str(drive, "");
61 ok_str(dir, "\\\\?\\c:\\dir1\\dir2\\");
62 }
63 ok_str(fname, "file");
64 ok_str(ext, ".ext");
65
66 _splitpath("ab:\\dir1\\..\\file", drive, dir, fname, ext);
67 ok_str(drive, "");
68 ok_str(dir, "ab:\\dir1\\..\\");
69 ok_str(fname, "file");
70 ok_str(ext, "");
71
72 _splitpath("//?/c:/dir1/dir2/file.ext", drive, dir, fname, ext);
73 ok_str(drive, "");
74 ok_str(dir, "//?/c:/dir1/dir2/");
75 ok_str(fname, "file");
76 ok_str(ext, ".ext");
77
78 _splitpath("\\\\?\\0:/dir1\\dir2/file.", drive, dir, fname, ext);
79 if (Major >= 6)
80 {
81 ok_str(drive, "0:");
82 ok_str(dir, "/dir1\\dir2/");
83 }
84 else
85 {
86 ok_str(drive, "");
87 ok_str(dir, "\\\\?\\0:/dir1\\dir2/");
88 }
89 ok_str(fname, "file");
90 ok_str(ext, ".");
91
92 _splitpath("\\\\.\\c:\\dir1\\dir2\\.ext.ext2", drive, dir, fname, ext);
93 ok_str(drive, "");
94 ok_str(dir, "\\\\.\\c:\\dir1\\dir2\\");
95 ok_str(fname, ".ext");
96 ok_str(ext, ".ext2");
97
98 _splitpath("\\??\\c:\\dir1\\dir2\\file. ~ ", drive, dir, fname, ext);
99 ok_str(drive, "");
100 ok_str(dir, "\\??\\c:\\dir1\\dir2\\");
101 ok_str(fname, "file");
102 ok_str(ext, ". ~ ");
103
104 _splitpath("x: dir1\\/dir2 \\.blub", drive, dir, fname, ext);
105 ok_str(drive, "x:");
106 ok_str(dir, " dir1\\/dir2 \\");
107 ok_str(fname, "");
108 ok_str(ext, ".blub");
109
110 _splitpath("/:\\dir1\\dir2\\file.ext", drive, dir, fname, ext);
111 ok_str(drive, "/:");
112 ok_str(dir, "\\dir1\\dir2\\");
113 ok_str(fname, "file");
114 ok_str(ext, ".ext");
115
116}
#define EINVAL
Definition: acclib.h:90
unsigned int dir
Definition: maze.c:112
#define ok_str(x, y)
Definition: atltest.h:127
#define ok_int(expression, result)
Definition: atltest.h:134
static const WCHAR *const ext[]
Definition: module.c:53
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP void __cdecl _splitpath(_In_z_ const char *_FullPath, _Pre_maybenull_ _Post_z_ char *_Drive, _Pre_maybenull_ _Post_z_ char *_Dir, _Pre_maybenull_ _Post_z_ char *_Filename, _Pre_maybenull_ _Post_z_ char *_Ext)
#define LOBYTE(W)
Definition: jmemdos.c:487
#define DWORD
Definition: nt_native.h:44
#define LOWORD(l)
Definition: pedump.c:82
DWORD WINAPI GetVersion()
Definition: redirtest.c:5
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:17
#define win_skip
Definition: test.h:163