Commit 859509ab authored by KO Myung-Hun's avatar KO Myung-Hun Committed by Rémi Denis-Courmont

Fix the problem that 'Open Directory...' does not work on OS/2

fpathconf (_PC_NAME_MAX) set errno to EBADF. This leads vlc_loaddir() to
misinterpret the result of vlc_readdir() if there are no more files.
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 3cabdc21
...@@ -190,8 +190,8 @@ char *vlc_readdir( DIR *dir ) ...@@ -190,8 +190,8 @@ char *vlc_readdir( DIR *dir )
struct dirent *ent; struct dirent *ent;
char *path = NULL; char *path = NULL;
#if !defined(__OS2__) || !defined(__KLIBC__)
long len = fpathconf (dirfd (dir), _PC_NAME_MAX); long len = fpathconf (dirfd (dir), _PC_NAME_MAX);
#if !defined(__OS2__) || !defined(__INNOTEK_LIBC__)
#ifdef NAME_MAX #ifdef NAME_MAX
/* POSIX says there shall we room for NAME_MAX bytes at all times */ /* POSIX says there shall we room for NAME_MAX bytes at all times */
if (/*len == -1 ||*/ len < NAME_MAX) if (/*len == -1 ||*/ len < NAME_MAX)
...@@ -202,12 +202,12 @@ char *vlc_readdir( DIR *dir ) ...@@ -202,12 +202,12 @@ char *vlc_readdir( DIR *dir )
return NULL; return NULL;
#endif #endif
len += offsetof (struct dirent, d_name) + 1; len += offsetof (struct dirent, d_name) + 1;
#else /* __OS2__ && __INNOTEK_LIBC__ */ #else /* __OS2__ && __KLIBC__ */
/* In the implementation of Innotek LIBC, aka kLIBC on OS/2, /* 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 * fpathconf (_PC_NAME_MAX) is broken, and errno is set to EBADF.
* of struct dirent. * Moreover, d_name is not the last member of struct dirent.
* So just allocate as many as the size of struct dirent. */ * So just allocate as many as the size of struct dirent. */
len = sizeof (struct dirent); long len = sizeof (struct dirent);
#endif #endif
struct dirent *buf = malloc (len); struct dirent *buf = malloc (len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment