fix dirname() implementation of Windows in lottieloader.cpp, and fix basename() imple...
authorVincent Torri <vincent.torri@gmail.com>
Mon, 1 Jul 2019 09:23:26 +0000 (11:23 +0200)
committerHermet Park <hermetpark@gmail.com>
Wed, 10 Jul 2019 01:56:56 +0000 (10:56 +0900)
example/lottie2gif.cpp
src/lottie/lottieloader.cpp

index ec295ec8d86d0287dfcf898f601e1f925dc19c56..cf75951a73a673ca4c423e03f8195872338fd087 100644 (file)
@@ -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;
         }
index 28b4e4b1ce42cf3c10331fbc817f92b4bf79a6d3..b39284e309fad133c61119968ad16f57ea2e3bee 100644 (file)
@@ -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);
 }