]> git.saurik.com Git - ldid.git/commitdiff
Replace Windows stat::st_mode with dirent::d_type.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 28 Sep 2015 10:16:41 +0000 (03:16 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 28 Sep 2015 10:16:41 +0000 (03:16 -0700)
ldid.cpp

index 9aff853f9caa00bfaae58e3f19c7495c6357eb40..bfa97b4f1fa92d53fd801873fbe454d8133c5f35 100644 (file)
--- 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());
+            }));
     }
 }