- #1200 Directory d_type==DT_UNKNOWN is now handled correctly (thanks to Jakub
  Wilk).
This commit is contained in:
Paul Beckingham 2013-04-13 13:37:16 -04:00
parent 0ea28ef8a3
commit 68a12908d2
2 changed files with 17 additions and 2 deletions

View file

@ -117,8 +117,14 @@ bool Directory::remove_directory (const std::string& dir)
else
unlink ((dir + "/" + de->d_name).c_str ());
#else
if (de->d_type == DT_DIR ||
de->d_type == DT_UNKNOWN)
if (de->d_type == DT_UNKNOWN)
{
struct stat s;
lstat ((dir + "/" + de->d_name).c_str (), &s);
if (s.st_mode & S_IFDIR)
de->d_type = DT_DIR;
}
if (de->d_type == DT_DIR)
remove_directory (dir + "/" + de->d_name);
else
unlink ((dir + "/" + de->d_name).c_str ());
@ -209,6 +215,13 @@ void Directory::list (
else
results.push_back (base + "/" + de->d_name);
#else
if (recursive && de->d_type == DT_UNKNOWN)
{
struct stat s;
lstat ((base + "/" + de->d_name).c_str (), &s);
if (s.st_mode & S_IFDIR)
de->d_type = DT_DIR;
}
if (recursive && de->d_type == DT_DIR)
list (base + "/" + de->d_name, results, recursive);
else