]> git.sesse.net Git - vlc/commitdiff
Fix vlc_readdir() for OS/2
authorKO Myung-Hun <komh@chollian.net>
Fri, 14 Oct 2011 12:22:04 +0000 (21:22 +0900)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 14 Oct 2011 14:59:03 +0000 (17:59 +0300)
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
src/posix/filesystem.c

index b33b485927527614a88f7acc37057e1d85ce13ca..eda796e1d0719438bd3c03bf190d09469f6770cd 100644 (file)
@@ -191,6 +191,7 @@ char *vlc_readdir( DIR *dir )
     char *path = NULL;
 
     long len = fpathconf (dirfd (dir), _PC_NAME_MAX);
+#if !defined(__OS2__) || !defined(__INNOTEK_LIBC__)
 #ifdef NAME_MAX
     /* POSIX says there shall we room for NAME_MAX bytes at all times */
     if (/*len == -1 ||*/ len < NAME_MAX)
@@ -201,6 +202,13 @@ char *vlc_readdir( DIR *dir )
         return NULL;
 #endif
     len += offsetof (struct dirent, d_name) + 1;
+#else /* __OS2__ && __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))