Use the secure version of splitpath

Fixes VC++ warning about possible buffer overruns.
This commit is contained in:
Robert Knight 2011-09-16 15:43:07 +01:00
parent 773edb5d53
commit 1898c7de69

View file

@ -298,7 +298,16 @@ std::string FileUtils::fileName(const char* path)
#else
char baseName[MAX_PATH];
char extension[MAX_PATH];
_splitpath(path, 0 /* drive */, 0 /* dir */, baseName, extension);
_splitpath_s(path,
0, /* drive */
0, /* drive length */
0, /* dir */
0, /* dir length */
baseName,
MAX_PATH, /* baseName length */
extension,
MAX_PATH /* extension length */
);
return std::string(baseName) + std::string(extension);
#endif
}
@ -312,7 +321,16 @@ std::string FileUtils::dirname(const char* path)
return dirname;
#else
char dir[MAX_PATH];
_splitpath(path, 0 /* drive */, dir, 0 /* filename */, 0/* extension */);
_splitpath_s(path,
0, /* drive */
0, /* drive length */
dir,
MAX_PATH, /* dir length */
0, /* filename */
0, /* filename length */
0, /* extension */
0 /* extension length */
);
return std::string(dir);
#endif
}