Changeset 5447:f72fce68ca19 for lib.c

Show
Ignore:
Timestamp:
2008-07-02 09:26:17 (5 months ago)
Author:
Vladimir Marek <Vladimir.Marek@…>
Branch:
HEAD
Message:

Use stat() instead of dirent->d_type to test for directory. Closes #3089.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lib.c

    r5438 r5447  
    4242#include <fcntl.h> 
    4343#include <pwd.h> 
     44#include <sys/types.h> 
    4445#include <dirent.h> 
    4546 
     
    584585  struct dirent* de; 
    585586  char cur[_POSIX_PATH_MAX]; 
     587  struct stat statbuf; 
    586588  int rc = 0; 
    587589 
     
    598600    snprintf (cur, sizeof (cur), "%s/%s", path, de->d_name); 
    599601    /* XXX make nonrecursive version */ 
    600     if (de->d_type == DT_DIR) 
     602 
     603    if (stat(cur, &statbuf) == -1) 
     604    { 
     605      rc = 1; 
     606      continue; 
     607    } 
     608 
     609    if (S_ISDIR (statbuf.st_mode)) 
    601610      rc |= mutt_rmtree (cur); 
    602611    else