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