Changeset 3915 for trunk/lilv/src/world.c
- Timestamp:
- 2012-01-04 11:21:12 (17 months ago)
- File:
-
- 1 edited
-
trunk/lilv/src/world.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lilv/src/world.c
r3908 r3915 15 15 */ 16 16 17 #define _POSIX_SOURCE 1 /* for wordexp*/17 #define _POSIX_SOURCE 1 /* for readdir_r */ 18 18 19 19 #include <assert.h> … … 25 25 26 26 #include "lilv_internal.h" 27 28 #ifdef HAVE_WORDEXP29 # include <wordexp.h>30 #endif31 27 32 28 LILV_API … … 583 579 } 584 580 585 /** Expand variables (e.g. POSIX ~ or $FOO, Windows %FOO%) in @a path. */586 static char*587 expand(const char* path)588 {589 #ifdef HAVE_WORDEXP590 char* ret = NULL;591 wordexp_t p;592 if (wordexp(path, &p, 0)) {593 LILV_ERRORF("Error expanding path `%s'\n", path);594 return lilv_strdup(path);595 }596 if (p.we_wordc == 0) {597 /* Literal directory path (e.g. no variables or ~) */598 ret = lilv_strdup(path);599 } else if (p.we_wordc == 1) {600 /* Directory path expands (e.g. contains ~ or $FOO) */601 ret = lilv_strdup(p.we_wordv[0]);602 } else {603 /* Multiple expansions in a single directory path? */604 LILV_ERRORF("Malformed path `%s' ignored\n", path);605 }606 wordfree(&p);607 #elif defined(__WIN32__)608 static const size_t len = 32767;609 char* ret = malloc(len);610 ExpandEnvironmentStrings(path, ret, len);611 #else612 char* ret = lilv_strdup(path);613 #endif614 return ret;615 }616 617 581 /** Load all bundles in the directory at @a dir_path. */ 618 582 static void 619 583 lilv_world_load_directory(LilvWorld* world, const char* dir_path) 620 584 { 621 char* path = expand(dir_path);585 char* path = lilv_expand(dir_path); 622 586 if (!path) { 623 587 LILV_WARNF("Empty path `%s'\n", path);
Note: See TracChangeset
for help on using the changeset viewer.
