From ae933c37aff8dc60caace2d97cad597da459331e Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Mon, 1 Jul 2019 11:23:26 +0200 Subject: [PATCH] fix dirname() implementation of Windows in lottieloader.cpp, and fix basename() implementation by using strrchr() and not strchr() --- example/lottie2gif.cpp | 4 ++-- src/lottie/lottieloader.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/example/lottie2gif.cpp b/example/lottie2gif.cpp index ec295ec8d8..cf75951a73 100644 --- a/example/lottie2gif.cpp +++ b/example/lottie2gif.cpp @@ -110,11 +110,11 @@ public: baseName = absoloutePath; #ifdef _WIN32 - char *base = strchr(baseName.data(), '/'); + char *base = strrchr(baseName.data(), '/'); if (base) { base++; - base = strchr(baseName.data(), '\\'); + base = strrchr(baseName.data(), '\\'); if (base) base++; else return 1; } diff --git a/src/lottie/lottieloader.cpp b/src/lottie/lottieloader.cpp index 28b4e4b1ce..b39284e309 100644 --- a/src/lottie/lottieloader.cpp +++ b/src/lottie/lottieloader.cpp @@ -71,6 +71,9 @@ public: static std::string dirname(const std::string &path) { const char *ptr = strrchr(path.c_str(), '/'); +#ifdef _WIN32 + if (ptr) ptr = strrchr(ptr + 1, '\\'); +#endif int len = int(ptr + 1 - path.c_str()); // +1 to include '/' return std::string(path, 0, len); }