aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-05-10 18:16:34 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-05-10 18:16:34 -0400
commita9abee3d7b57a094358ffbb460799d70fed7ef8b (patch)
tree4c1b8b501b2006df8abec25b48c4f007443582f8 /src
parent444e256efe52274caf464e941cd76abc9ccf1d61 (diff)
windows build
Diffstat (limited to 'src')
-rw-r--r--src/common.cpp30
-rw-r--r--src/ui.cpp2
2 files changed, 28 insertions, 4 deletions
diff --git a/src/common.cpp b/src/common.cpp
index 77be098..45ab5b6 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -15,13 +15,13 @@
#include <texture.hpp>
+#endif // __WIN32__
+
unsigned int millis(void) {
std::chrono::system_clock::time_point now=std::chrono::system_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
}
-#endif // __WIN32__
-
std::vector<std::string> StringTokenizer(const std::string& str, char delim)
{
std::vector<std::string> tokens;
@@ -61,6 +61,7 @@ void safeSetColorA(int r,int g,int b,int a) {
int getdir(std::string dir, std::vector<std::string> &files)
{
+#ifndef __WIN32__
DIR *dp;
struct dirent *dirp;
if (!(dp = opendir(dir.c_str()))) {
@@ -70,7 +71,30 @@ int getdir(std::string dir, std::vector<std::string> &files)
while((dirp = readdir(dp)))
files.push_back(std::string(dirp->d_name));
closedir(dp);
- return 0;
+#else
+ HANDLE dirh;
+ WIN32_FIND_DATA file_data;
+
+ if ((dirh = FindFirstFile((dir + "/*").c_str(), &file_data)) == INVALID_HANDLE_VALUE)
+ return -1; /* No files found */
+
+ do {
+ const std::string file_name = file_data.cFileName;
+ const std::string full_file_name = dir + file_name;
+ const bool is_directory = (file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
+
+ if (file_name[0] == '.')
+ continue;
+
+ if (is_directory)
+ continue;
+
+ files.push_back(file_name);
+ } while (FindNextFile(dirh, &file_data));
+
+ FindClose(dirh);
+#endif // __WIN32__
+ return 0;
}
void strVectorSortAlpha(std::vector<std::string> *v)
diff --git a/src/ui.cpp b/src/ui.cpp
index a57886c..384ce53 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -1007,7 +1007,7 @@ EXIT:
toggleBlackFast();
player->canMove = true;
};
-
+
while(SDL_PollEvent(&e)) {
switch(e.type) {