summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2015-09-28 03:16:41 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2015-09-28 03:16:41 -0700
commitb6d8da4eedd3fa6c2a7365fa5396f6e961dc1c39 (patch)
tree255e5bce403fa03200d433e08628687b5722d7e2
parent31cc0388669af2bf588eb53ad7285df26f47649c (diff)
downloadldid-b6d8da4eedd3fa6c2a7365fa5396f6e961dc1c39.tar.gz
ldid-b6d8da4eedd3fa6c2a7365fa5396f6e961dc1c39.tar.zst
ldid-b6d8da4eedd3fa6c2a7365fa5396f6e961dc1c39.zip
Replace Windows stat::st_mode with dirent::d_type.
-rw-r--r--ldid.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/ldid.cpp b/ldid.cpp
index 9aff853..bfa97b4 100644
--- a/ldid.cpp
+++ b/ldid.cpp
@@ -1584,25 +1584,41 @@ void DiskFolder::Find(const std::string &root, const std::string &base, const Fu
if (Starts(name, ".ldid."))
continue;
+ bool directory;
+
+#ifdef __WIN32__
+ struct stat info;
+ _syscall(stat(path.c_str(), &info));
+ if (false);
+ else if (S_ISDIR(info.st_mode))
+ directory = true;
+ else if (S_ISREG(info.st_mode))
+ directory = false;
+ else
+ _assert_(false, "st_mode=%x", info.st_mode);
+#else
switch (child->d_type) {
case DT_DIR:
- Find(root, base + name + "/", code);
- break;
-
+ directory = true;
+ break;
case DT_REG:
- code(base + name, fun([&](const Functor<void (std::streambuf &, std::streambuf &)> &code) {
- std::string access(root + base + name);
- _assert_(Open(access, fun([&](std::streambuf &data) {
- NullBuffer save;
- code(data, save);
- })), "open(): %s", access.c_str());
- }));
- break;
-
+ directory = false;
+ break;
default:
_assert_(false, "d_type=%u", child->d_type);
- break;
}
+#endif
+
+ if (directory)
+ Find(root, base + name + "/", code);
+ else
+ code(base + name, fun([&](const Functor<void (std::streambuf &, std::streambuf &)> &code) {
+ std::string access(root + base + name);
+ _assert_(Open(access, fun([&](std::streambuf &data) {
+ NullBuffer save;
+ code(data, save);
+ })), "open(): %s", access.c_str());
+ }));
}
}