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