4
4
// UT_splitpath - split a full path name
5
5
//
6
6
7
- #include < cstring>
8
- #include < fyut.h>
7
+ #include " stdafx.h"
9
8
10
9
void UT_splitFN (char *filename, char * name, char * ext) {
11
10
char * lastDot = strrchr (filename, ' .' );
@@ -43,21 +42,21 @@ CD char *extP o extension
43
42
CD ==============================================================
44
43
*/
45
44
SK_EntPnt_UT void UT_splitpath (const char *pathP, char *driveP, char *dirP, char *nameP, char *extP) {
46
- char local_path[PATH_MAX ]; /* Copy of pathP i case we modify it */
47
- char tmp[PATH_MAX ]; /* Copy of pathP i case we modify it */
48
- char filename[PATH_MAX ];
45
+ char local_path[_MAX_PATH ]; /* Copy of pathP i case we modify it */
46
+ char tmp[_MAX_PATH ]; /* Copy of pathP i case we modify it */
47
+ // char filename[_MAX_PATH ];
49
48
(*driveP) = (*dirP) = (*nameP) = (*extP) = ' \0 ' ;
50
49
51
- strcpy (local_path, pathP);
52
- strcpy (tmp, local_path);
50
+ UT_StrCopy (local_path, pathP, _MAX_PATH );
51
+ UT_StrCopy (tmp, local_path, _MAX_PATH );
53
52
/* Under linux, driveP is always \0 */
54
53
#ifdef WIN32
55
54
/* Afaik, there is only ONE : in windows filenames */
56
55
char * theColon = strrchr (tmp, ' :' );
57
56
if (theColon != NULL ) {
58
57
/* We overwrite local_path here, because after this the code
59
58
is equal for win/lin if the drive-part is removed */
60
- UT_StrCopy (local_path, theColon+1 , PATH_MAX );
59
+ UT_StrCopy (local_path, theColon+1 , _MAX_PATH );
61
60
(*(theColon + 1 )) = ' \0 ' ; // set a \0 after the color (inside tmp!)
62
61
UT_StrCopy (driveP, tmp, _MAX_DRIVE);
63
62
if (strlen (tmp) > _MAX_DRIVE) { // how would this even happen?
@@ -66,15 +65,15 @@ SK_EntPnt_UT void UT_splitpath(const char *pathP, char *driveP, char *dirP, char
66
65
}
67
66
#endif
68
67
69
- strcpy (tmp, local_path);
68
+ UT_StrCopy (tmp, local_path, _MAX_PATH );
70
69
71
70
char * lastSlash = strrchr (tmp, UT_SLASH);
72
71
73
72
/* Set dirP */
74
73
if (lastSlash != NULL ) {
75
74
/* +1 because we don't want the / in the filename */
76
- char filename[PATH_MAX ]; /* UT_splitFN might modify filename */
77
- strcpy (filename,lastSlash+1 );
75
+ char filename[_MAX_PATH ]; /* UT_splitFN might modify filename */
76
+ UT_StrCopy (filename,lastSlash+1 , _MAX_PATH );
78
77
if (strcmp (filename, " ." ) != 0 ) {
79
78
UT_splitFN (filename, nameP, extP);
80
79
(*(tmp + (lastSlash - tmp + 1 ))) = ' \0 ' ;
@@ -86,7 +85,7 @@ SK_EntPnt_UT void UT_splitpath(const char *pathP, char *driveP, char *dirP, char
86
85
}
87
86
} else {
88
87
if (strcmp (" ." , local_path) == 0 ) { /* Hard-coded to mimic old behaviour */
89
- strcpy (dirP, " ." );
88
+ UT_StrCopy (dirP, " ." , _MAX_DIR );
90
89
} else {
91
90
UT_splitFN (tmp, nameP, extP);
92
91
}
0 commit comments