[vlc-devel] [PATCH 29/41] Implement vlc_readdir() for OS/2
KO Myung-Hun
komh at chollian.net
Mon Oct 10 13:44:08 CEST 2011
---
src/posix/filesystem.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c
index f7c769d..011f9e6 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -191,6 +191,8 @@ char *vlc_readdir( DIR *dir )
char *path = NULL;
long len = fpathconf (dirfd (dir), _PC_NAME_MAX);
+
+#if !defined (__OS2__) || !defined(__INNOTEK_LIBC__)
if (len == -1)
{
#ifdef NAME_MAX
@@ -202,6 +204,14 @@ char *vlc_readdir( DIR *dir )
}
len += offsetof (struct dirent, d_name) + 1;
+#else /* !__OS2__ or !__INNOTEK_LIBC__ */
+ /* In the implementation of Innotek LIBC, aka kLIBC on OS/2,
+ * fpathconf (_PC_NAME_MAX) is broken, and d_name is not the last member
+ * of struct dirent.
+ * So just allocate as many as the size of struct dirent. */
+ len = sizeof (struct dirent);
+#endif
+
struct dirent *buf = malloc (len);
if (unlikely(buf == NULL))
return NULL;
@@ -210,10 +220,12 @@ char *vlc_readdir( DIR *dir )
if (val != 0)
errno = val;
else if (ent != NULL)
-#ifndef __APPLE__
- path = strdup (ent->d_name);
-#else
+#ifdef __APPLE__
path = FromCharset ("UTF-8-MAC", ent->d_name, strlen (ent->d_name));
+#elif defined (__OS2__)
+ path = FromCharset ("", ent->d_name, strlen (ent->d_name));
+#else
+ path = strdup (ent->d_name);
#endif
free (buf);
return path;
--
1.7.3.2
More information about the vlc-devel
mailing list