summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-08-13 23:55:59 +0000
committerDavid Robillard <d@drobilla.net>2015-08-13 23:55:59 +0000
commit8468b9a199358d76c2e4d1a0ef836373d5fc08cd (patch)
tree48466f2f44657b4c4e98dc67c41b96afbd89a7b5 /src
parent1cf47cc42caff696f77a49dc46370718bb7755dd (diff)
downloadlilv-8468b9a199358d76c2e4d1a0ef836373d5fc08cd.tar.gz
lilv-8468b9a199358d76c2e4d1a0ef836373d5fc08cd.tar.bz2
lilv-8468b9a199358d76c2e4d1a0ef836373d5fc08cd.zip
Fix lilv_realpath() on pre-POSIX-2008 systems.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5705 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/util.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/util.c b/src/util.c
index 31c9238..029cb92 100644
--- a/src/util.c
+++ b/src/util.c
@@ -14,8 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define _POSIX_C_SOURCE 1 /* for fileno */
-#define _BSD_SOURCE 1 /* for realpath, symlink */
+#define _POSIX_C_SOURCE 200809L /* for fileno */
+#define _BSD_SOURCE 1 /* for realpath, symlink */
#ifdef __APPLE__
# define _DARWIN_C_SOURCE 1 /* for flock */
@@ -430,13 +430,23 @@ lilv_get_latest_copy(const char* path, const char* copy_path)
char*
lilv_realpath(const char* path)
{
-#ifdef _WIN32
+#if defined(_WIN32)
char* out = (char*)malloc(MAX_PATH);
GetFullPathName(path, MAX_PATH, out, NULL);
return out;
-#else
+#elif _POSIX_VERSION >= 200809L
char* real_path = realpath(path, NULL);
return real_path ? real_path : lilv_strdup(path);
+#else
+ // OSX <= 105, if anyone cares. I sure don't.
+ char* out = (char*)malloc(PATH_MAX);
+ char* real_path = realpath(path, out);
+ if (!real_path) {
+ free(out);
+ return lilv_strdup(path);
+ } else {
+ return real_path;
+ }
#endif
}