summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-09-04 00:05:08 +0000
committerChris Wilson <chris+github@qwirx.com>2006-09-04 00:05:08 +0000
commit98009bbda2550b7e6aa28fd53f3daaa14d6cd577 (patch)
tree718961c55adcd33fde495113e2ac386edbd21d59 /lib
parent3f9f0196e6d437f225cfb14bce8b9b424def09ab (diff)
(refs #3)
Emulate readdir's d_type field
Diffstat (limited to 'lib')
-rw-r--r--lib/win32/emu.cpp10
-rw-r--r--lib/win32/emu.h5
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/win32/emu.cpp b/lib/win32/emu.cpp
index 423b3632..109e54f6 100644
--- a/lib/win32/emu.cpp
+++ b/lib/win32/emu.cpp
@@ -1002,7 +1002,7 @@ struct dirent *readdir(DIR *dp)
if (!dp->result.d_name ||
_wfindnext(dp->fd, &dp->info) != -1)
{
- den = &dp->result;
+ den = &dp->result;
std::wstring input(dp->info.name);
memset(tempbuff, 0, sizeof(tempbuff));
WideCharToMultiByte(CP_UTF8, 0, dp->info.name,
@@ -1010,6 +1010,14 @@ struct dirent *readdir(DIR *dp)
NULL, NULL);
//den->d_name = (char *)dp->info.name;
den->d_name = &tempbuff[0];
+ if (dp->info.attrib & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ den->d_type = S_IFDIR;
+ }
+ else
+ {
+ den->d_type = S_IFREG;
+ }
}
}
else
diff --git a/lib/win32/emu.h b/lib/win32/emu.h
index 2c4e1550..69daaa67 100644
--- a/lib/win32/emu.h
+++ b/lib/win32/emu.h
@@ -329,9 +329,14 @@ inline int strcasecmp(const char *s1, const char *s2)
}
#endif
+#ifdef _DIRENT_H_
+#error You must not include MinGW's dirent.h!
+#endif
+
struct dirent
{
char *d_name;
+ unsigned long d_type;
};
struct DIR