prepare move old cruft
[reactos.git] / reactos / lib / crtdll / old cruft / stdlib / splitp.c
1 #include <msvcrt/stdlib.h>
2 #include <msvcrt/string.h>
3
4
5 /*
6 * @implemented
7 */
8 void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext )
9 {
10 char *tmp_drive;
11 char *tmp_dir;
12 char *tmp_ext;
13
14 tmp_drive = (char *)strchr(path,':');
15 if ( tmp_drive != (char *)NULL ) {
16 strncpy(drive,tmp_drive-1,1);
17 *(drive+1) = 0;
18 }
19 else {
20 *drive = 0;
21 tmp_drive = (char *)path;
22 }
23
24 tmp_dir = (char *)strrchr(path,'\\');
25 if( tmp_dir != NULL && tmp_dir != tmp_drive + 1 ) {
26 strncpy(dir,tmp_drive+1,tmp_dir - tmp_drive);
27 *(dir + (tmp_dir - tmp_drive)) = 0;
28 }
29 else
30 *dir =0;
31
32 tmp_ext = ( char *)strrchr(path,'.');
33 if ( tmp_ext != NULL ) {
34 strcpy(ext,tmp_ext);
35 }
36 else
37 {
38 *ext = 0;
39 tmp_ext = (char*)path+strlen(path);
40 }
41 if ( tmp_dir != NULL ) {
42 strncpy(fname,tmp_dir+1,tmp_ext - tmp_dir - 1);
43 *(fname + (tmp_ext - tmp_dir -1)) = 0;
44 }
45 else
46 {
47 strncpy(fname,path,tmp_ext - path);
48 *(fname+(tmp_ext-path))=0;
49 }
50 }