Fix riscos path_add_part, to cope with the fact that newpart is unix-format

svn path=/trunk/netsurf/; revision=10767
This commit is contained in:
John Mark Bell 2010-09-13 18:20:08 +00:00
parent cd1afc2063
commit 91a0ef0622
1 changed files with 15 additions and 3 deletions

View File

@ -2492,18 +2492,30 @@ char *filename_from_path(char *path)
/**
* Add a path component/filename to an existing path
*
* \param path buffer containing path + free space
* \param path buffer containing platform-native format path + free space
* \param length length of buffer "path"
* \param newpart string containing path component to add to path
* \param newpart string containing unix-format path component to add to path
* \return true on success
*/
bool path_add_part(char *path, int length, const char *newpart)
{
if(path[strlen(path) - 1] != '.')
size_t path_len = strlen(path);
/* Append directory separator, if there isn't one */
if (path[path_len - 1] != '.') {
strncat(path, ".", length);
path_len += 1;
}
strncat(path, newpart, length);
/* Newpart is either a directory name, or a file leafname
* Either way, we must replace all dots with forward slashes */
for (path = path + path_len; *path; path++) {
if (*path == '.')
*path = '/';
}
return true;
}