2 * PROJECT: ReactOS Kernel
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * PURPOSE: CRT: implementation of _splitpath / _wsplitpath
5 * PROGRAMMERS: Timo Kreuzer
14 void _tsplitpath(const _TCHAR
* path
, _TCHAR
* drive
, _TCHAR
* dir
, _TCHAR
* fname
, _TCHAR
* ext
)
16 const _TCHAR
*src
, *dir_start
, *file_start
= 0, *ext_start
= 0;
18 /* Truncate all output strings */
19 if (drive
) drive
[0] = '\0';
20 if (dir
) dir
[0] = '\0';
21 if (fname
) fname
[0] = '\0';
22 if (ext
) ext
[0] = '\0';
35 //_Analysis_assume_(path != 0);
38 /* Skip '\\?\' prefix */
39 if ((path
[0] == '\\') && (path
[1] == '\\') &&
40 (path
[2] == '?') && (path
[3] == '\\')) path
+= 4;
43 if (path
[0] == '\0') return;
45 /* Check if we have a drive letter (only 1 char supported) */
57 /* Scan the rest of the string */
61 /* Remember last path seperator and last dot */
62 if ((*path
== '\\') || (*path
== '/')) file_start
= path
+ 1;
63 if (*path
== '.') ext_start
= path
;
67 /* Check if we got a file name / extension */
69 file_start
= dir_start
;
70 if (!ext_start
|| ext_start
< file_start
)
76 while (src
< file_start
) *dir
++ = *src
++;
83 while (src
< ext_start
) *fname
++ = *src
++;
90 while (*src
!= '\0') *ext
++ = *src
++;