diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/util.c | 46 |
2 files changed, 20 insertions, 29 deletions
@@ -1,5 +1,6 @@ lilv (0.22.1) unstable; + * Fix state file versioning * Unload contained resources when bundle is unloaded * Do not instantiate plugin when data fails to parse * Support re-loading plugins @@ -12,7 +13,7 @@ lilv (0.22.1) unstable; * Fix documentation installation * Fix outdated comment references to lilv_uri_to_path() - -- David Robillard <d@drobilla.net> Sat, 09 Jul 2016 20:45:46 -0400 + -- David Robillard <d@drobilla.net> Tue, 12 Jul 2016 21:22:40 -0400 lilv (0.22.0) stable; @@ -370,26 +370,8 @@ lilv_path_join(const char* a, const char* b) return path; } -static void -lilv_size_mtime(const char* path, off_t* size, time_t* time) -{ - struct stat buf; - if (stat(path, &buf)) { - LILV_ERRORF("stat(%s) (%s)\n", path, strerror(errno)); - return; - } - - if (size) { - *size = buf.st_size; - } - if (time) { - *time = buf.st_mtime; - } -} - typedef struct { char* pattern; - off_t orig_size; time_t time; char* latest; } Latest; @@ -397,16 +379,18 @@ typedef struct { static void update_latest(const char* path, const char* name, void* data) { - Latest* latest = (Latest*)data; - char* entry_path = lilv_path_join(path, name); + Latest* latest = (Latest*)data; + char* entry_path = lilv_path_join(path, name); unsigned num; if (sscanf(entry_path, latest->pattern, &num) == 1) { - off_t entry_size = 0; - time_t entry_time = 0; - lilv_size_mtime(entry_path, &entry_size, &entry_time); - if (entry_size == latest->orig_size && entry_time >= latest->time) { - free(latest->latest); - latest->latest = entry_path; + struct stat st; + if (!stat(entry_path, &st)) { + if (st.st_mtime >= latest->time) { + free(latest->latest); + latest->latest = entry_path; + } + } else { + LILV_ERRORF("stat(%s) (%s)\n", path, strerror(errno)); } } if (entry_path != latest->latest) { @@ -419,8 +403,14 @@ char* lilv_get_latest_copy(const char* path, const char* copy_path) { char* copy_dir = lilv_dirname(copy_path); - Latest latest = { lilv_strjoin(copy_path, "%u", NULL), 0, 0, NULL }; - lilv_size_mtime(path, &latest.orig_size, &latest.time); + Latest latest = { lilv_strjoin(copy_path, ".%u", NULL), 0, NULL }; + + struct stat st; + if (!stat(path, &st)) { + latest.time = st.st_mtime; + } else { + LILV_ERRORF("stat(%s) (%s)\n", path, strerror(errno)); + } lilv_dir_for_each(copy_dir, &latest, update_latest); |