Made safe version of string concat with delimiter

This commit is contained in:
Timo Strunk 2014-09-12 17:46:40 +02:00
parent 11b63cbe3d
commit c83dced0d2
2 changed files with 16 additions and 0 deletions

View File

@ -926,6 +926,18 @@ void fill_pathname_join(char *out_path,
rarch_assert(strlcat(out_path, path, size) < size);
}
void fill_pathname_join_delim(char *out_path, const char *dir,
const char *path, const char delim, size_t size)
{
size_t copied = strlcpy(out_path, dir, size);
rarch_assert(copied < size+1);
out_path[copied]=delim;
out_path[copied+1] = '\0';
rarch_assert(strlcat(out_path, path, size) < size);
}
void fill_pathname_expand_special(char *out_path,
const char *in_path, size_t size)
{

View File

@ -193,6 +193,10 @@ void fill_pathname_resolve_relative(char *out_path, const char *in_refpath,
void fill_pathname_join(char *out_path, const char *dir,
const char *path, size_t size);
/* Joins a directory and path together using the given char. */
void fill_pathname_join_delim(char *out_path, const char *dir,
const char *path, const char delim, size_t size);
/* Generates a short representation of path. It should only
* be used for displaying the result; the output representation is not
* binding in any meaningful way (for a normal path, this is the same as basename)