Skip to content

Commit

Permalink
Common: fixed _splitpath() linux implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg committed Oct 10, 2018
1 parent ebaee68 commit 7efe754
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Common/PlatformLinux.inl
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,31 @@ inline void _splitpath (
strcpy(drive, "");

if(dir) {
strcpy(dir, dirname(tmp));
char tmp_dir[PATH_MAX] = {0};
strcpy(tmp_dir, tmp); // W/A for fname broking
strcpy(dir, dirname(tmp_dir)); // This eval modify dirname argument!!!
if (dir[0] && dir[strlen(dir) - 1] != '/')
strcat(dir, "/");
}

if(fname)
{
strcpy(fname, basename(tmp));
char *pos = strrchr(fname, '.');
if(pos != NULL)
*pos = 0;
}

if(ext)
{
char tmp_ext[NAME_MAX] = { 0 };
strcpy(tmp_ext, basename(tmp));
char *pos = strrchr(fname, '.');
if(pos != NULL)
strcpy(ext, pos + 1);
else
strcpy(ext, "");
}
}

#include <iostream>
Expand Down

0 comments on commit 7efe754

Please sign in to comment.