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 ec295ec..cf75951 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 28b4e4b..b39284e 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);
 }