This test program doesn't work (under win2k at least) :
<BEGIN tstopendir.c>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#if defined(__MINGW32__)||defined(__CYGWIN__)||defined(_unix)
#include <unistd.h>
#endif
#include <dirent.h>
// Mingw32 doesn't seem to have S_IFLNK defined
#if !defined(S_IFLNK)
# define S_IFLNK 0xa000
#endif
#if !defined(PATH_MAX)
#define PATH_MAX 254
#endif
int proc(const char *szDirPath)
{
char cType,
fname[PATH_MAX],
str[PATH_MAX];
DIR *pDir;
struct dirent *pDirent;
struct stat Stat;
printf\(&quot;tstopendir : opendir\(\&quot;%s\&quot;\)\n&quot;,szDirPath\);
// opendir() gives an errno=2 if the path has an / or \ at
// the end, else it gives a segfault
pDir=opendir(szDirPath);
printf("opendir returned %s\n",pDir?"true":"false");
if(!pDir)
{
fprintf(stderr,"%s: can't opendir (errno=%u=0x%0x)\n",
szDirPath,errno,errno);
return 2;
}
for(*fname=0;;)
{
pDirent=readdir(pDir);
if(!pDirent)
break;
strcpy\(fname,pDirent-&gt;d\_name\);
// Ask for more informations about the file
sprintf\(str,&quot;%s/%s&quot;,szDirPath,fname\);
stat\(str,&amp;Stat\);
if\(Stat.st\_mode&amp;S\_IFDIR\)
cType='d';
else
if\(Stat.st\_mode&amp;S\_IFREG\)
cType='-';
else
if\(Stat.st\_mode&amp;S\_IFLNK\)
cType='l';
else
cType='?';
printf\(&quot;%c %12lu %s\n&quot;,cType,Stat.st\_size,fname\);
\}
closedir\(pDir\);
return 0;
}
int main(int argc,char **argv)
{
if(argc!=2)
{
fprintf(stderr,"usage: %s path",argv[0]);
return 1;
}
return proc\(argv\[1\]\);
}
<END tstopendir.c>
Now it works back with mingw-runtime-0.4.tar.gz !
Logged In: YES
user_id=15438
Is this still an issue???
Earnie.
Logged In: YES
user_id=25461
Hi, no it's no more an issue, it only failed with mingw-
runtime-0.4-20001204, I never understood why.
So you can consider this case closed!
Although closed, it may be worth noting that the dirent.c module, (which provides opendir() and friends), has been completely reworked for WSL; the reworked version is not ABI compatible with the old.
We should note this in the Release Notes and we'll need to release a new GCC/binutils set at the same time.
Added to NEWS file.