ReactOS 0.4.15-dev-7953-g1f49173
_tsplitpath_x.h File Reference
#include <precomp.h>
#include <tchar.h>
#include <mbctype.h>
Include dependency graph for _tsplitpath_x.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _FAILURE
 
#define _SUCCESS
 

Functions

_CRTIMP void __cdecl _tsplitpath_x (_In_z_ const _TCHAR *path, _Pre_maybenull_ _Post_z_ _TCHAR *drive, _Pre_maybenull_ _Post_z_ _TCHAR *dir, _Pre_maybenull_ _Post_z_ _TCHAR *fname, _Pre_maybenull_ _Post_z_ _TCHAR *ext)
 

Macro Definition Documentation

◆ _FAILURE

#define _FAILURE

Definition at line 31 of file _tsplitpath_x.h.

◆ _SUCCESS

#define _SUCCESS

Definition at line 32 of file _tsplitpath_x.h.

Function Documentation

◆ _tsplitpath_x()

Definition at line 38 of file _tsplitpath_x.h.

45{
46 const _TCHAR *src, *dir_start, *file_start = 0, *ext_start = 0;
47 size_t count;
48#if !IS_SECAPI
49 const size_t drive_size = INT_MAX, dir_size = INT_MAX,
50 fname_size = INT_MAX, ext_size = INT_MAX;
51#endif
52
53#if IS_SECAPI
54 /* Validate parameters */
55 if (MSVCRT_CHECK_PMT((path == NULL) ||
56 ((drive != NULL) && (drive_size == 0)) ||
57 ((dir != NULL) && (dir_size == 0)) ||
58 ((fname != NULL) && (fname_size == 0)) ||
59 ((ext != NULL) && (ext_size == 0))))
60 {
61 errno = EINVAL;
62 return -1;
63 }
64#endif
65
66 /* Truncate all output strings */
67 if (drive) drive[0] = '\0';
68 if (dir) dir[0] = '\0';
69 if (fname) fname[0] = '\0';
70 if (ext) ext[0] = '\0';
71
72#if WINVER >= 0x600
73 /* Check parameter */
74 if (!path)
75 {
76#ifndef _LIBCNT_
78#endif
79 return _FAILURE;
80 }
81#endif
82
84
85#if WINVER == 0x600
86 /* Skip '\\?\' prefix */
87 if ((path[0] == '\\') && (path[1] == '\\') &&
88 (path[2] == '?') && (path[3] == '\\')) path += 4;
89#endif
90
91 if (path[0] == '\0') return _FAILURE;
92
93 /* Check if we have a drive letter (only 1 char supported) */
94 if (path[1] == ':')
95 {
96 if (drive && (drive_size >= 3))
97 {
98 drive[0] = path[0];
99 drive[1] = ':';
100 drive[2] = '\0';
101 }
102 path += 2;
103 }
104
105 /* Scan the rest of the string */
106 dir_start = path;
107 while (*path != '\0')
108 {
109#if !defined(_UNICODE) && !defined(_LIBCNT_)
110 /* Check for multibyte lead bytes */
111 if (_ismbblead((unsigned char)*path))
112 {
113 /* Check for unexpected end of string */
114 if (path[1] == 0) break;
115
116 /* Skip the lead byte and the following byte */
117 path += 2;
118 continue;
119 }
120#endif
121 /* Remember last path separator and last dot */
122 if ((*path == '\\') || (*path == '/')) file_start = path + 1;
123 if (*path == '.') ext_start = path;
124 path++;
125 }
126
127 /* Check if we got a file name / extension */
128 if (!file_start)
129 file_start = dir_start;
130 if (!ext_start || (ext_start < file_start))
131 ext_start = path;
132
133 if (dir)
134 {
135 src = dir_start;
136 count = dir_size - 1;
137 while ((src < file_start) && count--) *dir++ = *src++;
138 *dir = '\0';
139 }
140
141 if (fname)
142 {
143 src = file_start;
144 count = fname_size - 1;
145 while (src < ext_start && count--) *fname++ = *src++;
146 *fname = '\0';
147 }
148
149 if (ext)
150 {
151 src = ext_start;
152 count = ext_size - 1;
153 while (*src != '\0' && count--) *ext++ = *src++;
154 *ext = '\0';
155 }
156
157 return _SUCCESS;
158}
#define _FAILURE
Definition: _tsplitpath_x.h:31
#define _SUCCESS
Definition: _tsplitpath_x.h:32
#define EINVAL
Definition: acclib.h:90
unsigned int dir
Definition: maze.c:112
#define NULL
Definition: types.h:112
static const WCHAR *const ext[]
Definition: module.c:53
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum src
Definition: glext.h:6340
#define INT_MAX
Definition: limits.h:40
char _TCHAR
Definition: tchar.h:1392
#define MSVCRT_CHECK_PMT(x)
Definition: mbstowcs_s.c:26
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20
#define _Analysis_assume_(expr)
Definition: ms_sal.h:2901
#define errno
Definition: errno.h:18
errno_t __cdecl _set_errno(_In_ int _Value)
LOCAL int ext_size(UInt32_t starting_extent)
Definition: write.c:2503