Skip to content

Commit

Permalink
COMP: Use std <filesystem> instead of POSIX "dirent.h"
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanz committed Aug 27, 2024
1 parent 9339e97 commit eb18d0d
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions include/IRPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#if defined(WIN32)
#pragma warning ( disable : 4996 )
#endif
#include "dirent.h"
#include <filesystem>
#if defined(WIN32)
#pragma warning ( default : 4996 )
#endif
Expand Down Expand Up @@ -84,30 +84,14 @@ class IRPath
static std::list<the_text_t> DirectoryContents(const the_text_t &path)
{
std::list<the_text_t> files;

DIR *dp;
struct dirent *dirp;
if((dp = opendir(path.text())) == NULL) {
cout << "Error(" << errno << ") opening " << path << endl;
return files;
}

while ((dirp = readdir(dp)) != NULL) {
files.push_back( dirp->d_name );
}
closedir(dp);

// Remove .
files.pop_front();

// Remove ..
files.pop_front();
for (const auto & entry : std::filesystem::directory_iterator(path.text()))
{
files.push_back(entry.path().filename().string().c_str());
}

return files;
}

};

#endif


0 comments on commit eb18d0d

Please sign in to comment.