From 68a12908d26e25c0404728d63a248f2770b4c29e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 13 Apr 2013 13:37:16 -0400 Subject: [PATCH] Bug #1200 - #1200 Directory d_type==DT_UNKNOWN is now handled correctly (thanks to Jakub Wilk). --- ChangeLog | 2 ++ src/Directory.cpp | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e59654f8..f8316e0c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,8 @@ Features Bugs + #1196 Now builds on Hurd (thanks to Jakub Wilk). + #1197 Now 'tasksh' recognizes Ctrl-D to exit. + + #1200 Directory d_type==DT_UNKNOWN is now handled correctly (thanks to Jakub + Wilk). + #1211 The 'dateformat' settings now default to the ISO-8601 standard of 'Y-M-D' (thanks to Robin Björklin). + #1222 The 'summary' report now obeys the 'color.label' setting (thanks to diff --git a/src/Directory.cpp b/src/Directory.cpp index b4ee4b914..b666d11b3 100644 --- a/src/Directory.cpp +++ b/src/Directory.cpp @@ -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