Path/Directory

- Uses proper macros for st_mode inspection (thanks to Wim Schuermann).
This commit is contained in:
Paul Beckingham 2014-05-18 12:18:35 -04:00
parent 550d592abe
commit e7af475a2e
2 changed files with 6 additions and 6 deletions

View file

@ -111,7 +111,7 @@ bool Directory::remove_directory (const std::string& dir) const
#if defined (SOLARIS) || defined (HAIKU) #if defined (SOLARIS) || defined (HAIKU)
struct stat s; struct stat s;
lstat ((dir + "/" + de->d_name).c_str (), &s); lstat ((dir + "/" + de->d_name).c_str (), &s);
if (s.st_mode & S_IFDIR) if (S_ISDIR (s.st_mode))
remove_directory (dir + "/" + de->d_name); remove_directory (dir + "/" + de->d_name);
else else
unlink ((dir + "/" + de->d_name).c_str ()); unlink ((dir + "/" + de->d_name).c_str ());
@ -120,7 +120,7 @@ bool Directory::remove_directory (const std::string& dir) const
{ {
struct stat s; struct stat s;
lstat ((dir + "/" + de->d_name).c_str (), &s); lstat ((dir + "/" + de->d_name).c_str (), &s);
if (s.st_mode & S_IFDIR) if (S_ISDIR (s.st_mode))
de->d_type = DT_DIR; de->d_type = DT_DIR;
} }
if (de->d_type == DT_DIR) if (de->d_type == DT_DIR)
@ -215,7 +215,7 @@ void Directory::list (
#if defined (SOLARIS) || defined (HAIKU) #if defined (SOLARIS) || defined (HAIKU)
struct stat s; struct stat s;
stat ((base + "/" + de->d_name).c_str (), &s); stat ((base + "/" + de->d_name).c_str (), &s);
if (recursive && s.st_mode & S_IFDIR) if (recursive && S_ISDIR (s.st_mode))
list (base + "/" + de->d_name, results, recursive); list (base + "/" + de->d_name, results, recursive);
else else
results.push_back (base + "/" + de->d_name); results.push_back (base + "/" + de->d_name);
@ -224,7 +224,7 @@ void Directory::list (
{ {
struct stat s; struct stat s;
lstat ((base + "/" + de->d_name).c_str (), &s); lstat ((base + "/" + de->d_name).c_str (), &s);
if (s.st_mode & S_IFDIR) if (S_ISDIR (s.st_mode))
de->d_type = DT_DIR; de->d_type = DT_DIR;
} }
if (recursive && de->d_type == DT_DIR) if (recursive && de->d_type == DT_DIR)

View file

@ -161,7 +161,7 @@ bool Path::is_directory () const
{ {
struct stat s = {0}; struct stat s = {0};
if (! stat (_data.c_str (), &s) && if (! stat (_data.c_str (), &s) &&
s.st_mode & S_IFDIR) S_ISDIR (s.st_mode))
return true; return true;
return false; return false;
@ -181,7 +181,7 @@ bool Path::is_link () const
{ {
struct stat s = {0}; struct stat s = {0};
if (! lstat (_data.c_str (), &s) && if (! lstat (_data.c_str (), &s) &&
s.st_mode & S_IFLNK) S_ISLNK (s.st_mode))
return true; return true;
return false; return false;