aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-01-07 09:28:43 -0500
committerClyne Sullivan <tullivan99@gmail.com>2016-01-07 09:28:43 -0500
commit0c89c034ffe5fdf79e57c8bdbe9ca07eaf79b382 (patch)
tree0433130e467a03d5df45b5748676febe3506deaf /src/common.cpp
parent42bd0ae7913af00ea5e330e45321e2bbe9e734d9 (diff)
xml
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp
index dbcef0b..8defd61 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -4,6 +4,13 @@
#include <chrono>
#ifndef __WIN32__
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include <vector>
+#endif // __WIN32__
+
+#ifndef __WIN32__
unsigned int millis(void){
std::chrono::system_clock::time_point now=std::chrono::system_clock::now();
@@ -57,3 +64,16 @@ void safeSetColorA(int r,int g,int b,int a){
if(a<0)a=0;
glColor4ub(r,g,b,a);
}
+
+int getdir(const char *dir, std::vector<std::string> &files){
+ DIR *dp;
+ struct dirent *dirp;
+ if(!(dp = opendir(dir))){
+ std::cout <<"Error ("<<errno<<") opening "<<dir<<std::endl;
+ return errno;
+ }
+ while((dirp = readdir(dp)))
+ files.push_back(std::string(dirp->d_name));
+ closedir(dp);
+ return 0;
+}