Convert build process to autotools
Replaced the use of a manual Makefile with the use of autotools to
automatically verify and generate the necessary build files. Follow the
steps outlined within the README.md file to build the package.
Change-Id: Ieed870c63b2bef83b3741dd22e413c25916ed408
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/directory.cpp b/directory.cpp
new file mode 100644
index 0000000..93cf5d5
--- /dev/null
+++ b/directory.cpp
@@ -0,0 +1,38 @@
+#include <cerrno>
+#include <cstring>
+#include <iostream>
+#include "directory.hpp"
+
+Directory::Directory(const std::string& path) : entry(nullptr)
+{
+ dirp = opendir(path.c_str());
+ if (NULL == dirp)
+ {
+ auto e = errno;
+ std::cerr << "Error opening directory " << path.c_str()
+ << " : " << strerror(e) << std::endl;
+ }
+}
+
+Directory::~Directory()
+{
+ if (dirp)
+ {
+ closedir(dirp);
+ }
+}
+
+bool Directory::next(std::string& name)
+{
+ if (!dirp) return false;
+
+ dirent entry;
+ dirent* result;
+
+ auto rc = readdir_r(dirp, &entry, &result);
+
+ if ((rc) || (NULL == result)) return false;
+
+ name = entry.d_name;
+ return true;
+}