mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 05:26:48 +00:00
lottie2gif.cpp: use _fullpath() instead of realpath() and mimic basename() 2 strchr()
Notes: 1) arguments of realpath() and _fullpath() are in reverse order 2) 2 calls of strchr() are needed because / and \ are valid path separators on Windows
This commit is contained in:
parent
6963112f0f
commit
6c35e4f641
@ -9,6 +9,7 @@
|
|||||||
#include<libgen.h>
|
#include<libgen.h>
|
||||||
#else
|
#else
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class GifBuilder {
|
class GifBuilder {
|
||||||
@ -92,7 +93,6 @@ public:
|
|||||||
return result();
|
return result();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
int setup(int argc, char **argv)
|
int setup(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc > 1) fileName = argv[1];
|
if (argc > 1) fileName = argv[1];
|
||||||
@ -100,22 +100,30 @@ public:
|
|||||||
|
|
||||||
if (!fileName) return help();
|
if (!fileName) return help();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
fileName = _fullpath(absoloutePath.data(), fileName, absoloutePath.size());
|
||||||
|
#else
|
||||||
fileName = realpath(fileName, absoloutePath.data());
|
fileName = realpath(fileName, absoloutePath.data());
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!fileName || !jsonFile(fileName) ) return help();
|
if (!fileName || !jsonFile(fileName) ) return help();
|
||||||
|
|
||||||
baseName = absoloutePath;
|
baseName = absoloutePath;
|
||||||
|
#ifdef _WIN32
|
||||||
|
char *base = strchr(baseName.data(), '/');
|
||||||
|
if (base)
|
||||||
|
{
|
||||||
|
base++;
|
||||||
|
base = strchr(baseName.data(), '\\');
|
||||||
|
if (base) base++;
|
||||||
|
else return 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
char *base = basename(baseName.data());
|
char *base = basename(baseName.data());
|
||||||
|
#endif
|
||||||
snprintf(baseName.data(), baseName.size(), "%s.gif",base);
|
snprintf(baseName.data(), baseName.size(), "%s.gif",base);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
int setup(int argc, char **argv)
|
|
||||||
{
|
|
||||||
std::cout<<"Yet to implement in Windows\m";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user