From: <no...@so...> - 2001-01-03 09:54:55
|
Bug #127383, was updated on 2001-Jan-03 01:54 Here is a current snapshot of the bug. Project: MinGW - Minimalist GNU for Windows Category: None Status: Open Resolution: None Bug Group: None Priority: 5 Submitted by: hparissi Assigned to : nobody Summary: opendir() failed (mingw-runtime-0.4-20001204) Details: 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("tstopendir : opendir(\"%s\")\n",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->d_name); // Ask for more informations about the file sprintf(str,"%s/%s",szDirPath,fname); stat(str,&Stat); if(Stat.st_mode&S_IFDIR) cType='d'; else if(Stat.st_mode&S_IFREG) cType='-'; else if(Stat.st_mode&S_IFLNK) cType='l'; else cType='?'; printf("%c %12lu %s\n",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> For detailed info, follow this link: http://sourceforge.net/bugs/?func=detailbug&bug_id=127383&group_id=2435 |