Ignore:
Timestamp:
01/04/12 11:21:12 (3 years ago)
Author:
drobilla
Message:

Implement proper support for LV2_STATE_BUNDLE.
Test saving state to default bundle path.
Fix memory leaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lilv/src/world.c

    r3908 r3915  
    1515*/ 
    1616 
    17 #define _POSIX_SOURCE 1 /* for wordexp */ 
     17#define _POSIX_SOURCE 1  /* for readdir_r */ 
    1818 
    1919#include <assert.h> 
     
    2525 
    2626#include "lilv_internal.h" 
    27  
    28 #ifdef HAVE_WORDEXP 
    29 #    include <wordexp.h> 
    30 #endif 
    3127 
    3228LILV_API 
     
    583579} 
    584580 
    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_WORDEXP 
    590     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 #else 
    612     char* ret = lilv_strdup(path); 
    613 #endif 
    614     return ret; 
    615 } 
    616  
    617581/** Load all bundles in the directory at @a dir_path. */ 
    618582static void 
    619583lilv_world_load_directory(LilvWorld* world, const char* dir_path) 
    620584{ 
    621     char* path = expand(dir_path); 
     585    char* path = lilv_expand(dir_path); 
    622586    if (!path) { 
    623587        LILV_WARNF("Empty path `%s'\n", path); 
Note: See TracChangeset for help on using the changeset viewer.