diff options
author | David Robillard <d@drobilla.net> | 2012-01-09 15:57:45 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-01-09 15:57:45 +0000 |
commit | bb733c2283b7f9ffb1f05d57457475adb91bd04a (patch) | |
tree | 161c67f269b699ca0db0e1231d1ceeac186045ec /src/util.c | |
parent | 682cdde237bdcd1a804f7a2dd740d7c1f80ab838 (diff) | |
download | lilv-bb733c2283b7f9ffb1f05d57457475adb91bd04a.tar.gz lilv-bb733c2283b7f9ffb1f05d57457475adb91bd04a.tar.bz2 lilv-bb733c2283b7f9ffb1f05d57457475adb91bd04a.zip |
Make lilv_state_save take a full filename with extension.
Use a proper path joining function for separator normalisation.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3927 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -256,6 +256,21 @@ lilv_path_is_absolute(const char* path) return false; } +char* +lilv_path_join(const char* a, const char* b) +{ + const size_t a_len = strlen(a); + const size_t b_len = strlen(b); + const size_t pre_len = a_len - (lilv_is_dir_sep(a[a_len - 1]) ? 1 : 0); + char* path = calloc(1, a_len + b_len + 2); + memcpy(path, a, pre_len); + path[pre_len] = LILV_DIR_SEP[0]; + memcpy(path + pre_len + 1, + b + (lilv_is_dir_sep(b[0]) ? 1 : 0), + lilv_is_dir_sep(b[0]) ? b_len - 1 : b_len); + return path; +} + static void lilv_size_mtime(const char* path, off_t* size, time_t* time) { |