From b6d8da4eedd3fa6c2a7365fa5396f6e961dc1c39 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 28 Sep 2015 03:16:41 -0700 Subject: [PATCH] Replace Windows stat::st_mode with dirent::d_type. --- ldid.cpp | 42 +++++++++++++++++++++++++++++------------- 1 file 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 &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 &code) { + std::string access(root + base + name); + _assert_(Open(access, fun([&](std::streambuf &data) { + NullBuffer save; + code(data, save); + })), "open(): %s", access.c_str()); + })); } } -- 2.45.2