diff options
author | David Robillard <d@drobilla.net> | 2012-01-04 19:21:12 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-01-04 19:21:12 +0000 |
commit | 7823f743ee0c748ff4ced56838cd737516d857ab (patch) | |
tree | 083bcfd6edb27c53aa217da644f650e86f270070 /src/world.c | |
parent | 2f71e8570bcd37ad681bde7d51c433701a0028ab (diff) | |
download | lilv-7823f743ee0c748ff4ced56838cd737516d857ab.tar.gz lilv-7823f743ee0c748ff4ced56838cd737516d857ab.tar.bz2 lilv-7823f743ee0c748ff4ced56838cd737516d857ab.zip |
Implement proper support for LV2_STATE_BUNDLE.
Test saving state to default bundle path.
Fix memory leaks.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3915 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/world.c')
-rw-r--r-- | src/world.c | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/src/world.c b/src/world.c index 2029136..8151a73 100644 --- a/src/world.c +++ b/src/world.c @@ -14,7 +14,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define _POSIX_SOURCE 1 /* for wordexp */ +#define _POSIX_SOURCE 1 /* for readdir_r */ #include <assert.h> #include <errno.h> @@ -25,10 +25,6 @@ #include "lilv_internal.h" -#ifdef HAVE_WORDEXP -# include <wordexp.h> -#endif - LILV_API LilvWorld* lilv_world_new(void) @@ -582,43 +578,11 @@ lilv_world_load_bundle(LilvWorld* world, LilvNode* bundle_uri) serd_node_free(&manifest_uri); } -/** Expand variables (e.g. POSIX ~ or $FOO, Windows %FOO%) in @a path. */ -static char* -expand(const char* path) -{ -#ifdef HAVE_WORDEXP - char* ret = NULL; - wordexp_t p; - if (wordexp(path, &p, 0)) { - LILV_ERRORF("Error expanding path `%s'\n", path); - return lilv_strdup(path); - } - if (p.we_wordc == 0) { - /* Literal directory path (e.g. no variables or ~) */ - ret = lilv_strdup(path); - } else if (p.we_wordc == 1) { - /* Directory path expands (e.g. contains ~ or $FOO) */ - ret = lilv_strdup(p.we_wordv[0]); - } else { - /* Multiple expansions in a single directory path? */ - LILV_ERRORF("Malformed path `%s' ignored\n", path); - } - wordfree(&p); -#elif defined(__WIN32__) - static const size_t len = 32767; - char* ret = malloc(len); - ExpandEnvironmentStrings(path, ret, len); -#else - char* ret = lilv_strdup(path); -#endif - return ret; -} - /** Load all bundles in the directory at @a dir_path. */ static void lilv_world_load_directory(LilvWorld* world, const char* dir_path) { - char* path = expand(dir_path); + char* path = lilv_expand(dir_path); if (!path) { LILV_WARNF("Empty path `%s'\n", path); return; |