BLI_path_util: assert to ensure BLI_join_dirfile is used correctly
This commit is contained in:
parent
a06abbac92
commit
d4d38e8a34
|
@ -1730,6 +1730,9 @@ void BLI_path_append(char *__restrict dst, const size_t maxlen, const char *__re
|
|||
/**
|
||||
* Simple appending of filename to dir, does not check for valid path!
|
||||
* Puts result into `dst`, which may be same area as `dir`.
|
||||
*
|
||||
* \note Consider using #BLI_path_join for more general path joining
|
||||
* that de-duplicates separators and can handle an arbitrary number of paths.
|
||||
*/
|
||||
void BLI_join_dirfile(char *__restrict dst,
|
||||
const size_t maxlen,
|
||||
|
@ -1741,9 +1744,13 @@ void BLI_join_dirfile(char *__restrict dst,
|
|||
#endif
|
||||
size_t dirlen = BLI_strnlen(dir, maxlen);
|
||||
|
||||
/* args can't match */
|
||||
/* Arguments can't match. */
|
||||
BLI_assert(!ELEM(dst, dir, file));
|
||||
|
||||
/* Files starting with a separator cause a double-slash which could later be interpreted
|
||||
* as a relative path where: `dir == "/"` and `file == "/file"` would result in "//file". */
|
||||
BLI_assert(file[0] != SEP);
|
||||
|
||||
if (dirlen == maxlen) {
|
||||
memcpy(dst, dir, dirlen);
|
||||
dst[dirlen - 1] = '\0';
|
||||
|
|
Loading…
Reference in New Issue