1 #include <msvcrt/stdlib.h>
2 #include <msvcrt/string.h>
4 void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext )
10 tmp_drive = (char *)strchr(path,':');
11 if ( tmp_drive != (char *)NULL ) {
12 strncpy(drive,tmp_drive-1,1);
17 tmp_drive = (char *)path;
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;
28 tmp_ext = ( char *)strrchr(path,'.');
29 if ( tmp_ext != NULL ) {
35 tmp_ext = (char *)path+strlen(path);
37 if ( tmp_dir != NULL ) {
38 strncpy(fname,tmp_dir+1,tmp_ext - tmp_dir - 1);
39 *(fname + (tmp_ext - tmp_dir -1)) = 0;
43 strncpy(fname,path,tmp_ext - path);
44 *(fname+(tmp_ext-path))=0;
48 void _wsplitpath( const wchar_t *path, wchar_t *drive, wchar_t *dir, wchar_t *fname, wchar_t *ext )
54 tmp_drive = (wchar_t *)wcschr(path,L':');
55 if ( tmp_drive != (wchar_t *)NULL ) {
56 wcsncpy(drive,tmp_drive-1,1);
61 tmp_drive = (wchar_t *)path;
64 tmp_dir = (wchar_t *)wcsrchr(path,L'\\');
65 if( tmp_dir != NULL && tmp_dir != tmp_drive + 1 ) {
66 wcsncpy(dir,tmp_drive+1,tmp_dir - tmp_drive);
67 *(dir + (tmp_dir - tmp_drive)) = 0;
72 tmp_ext = (wchar_t *)wcsrchr(path,L'.');
73 if ( tmp_ext != NULL ) {
79 tmp_ext = (wchar_t *)path+wcslen(path);
82 if ( tmp_dir != NULL ) {
83 wcsncpy(fname,tmp_dir+1,tmp_ext - tmp_dir - 1);
84 *(fname + (tmp_ext - tmp_dir -1)) = 0;
88 wcsncpy(fname,path,tmp_ext - path);
89 *(fname+(tmp_ext-path))=0;