mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-01 17:25:02 +00:00
Fix compile error on some platform
This commit is contained in:
3 files changed
+33
-15
No files matched your search
+25
-11
@@ -8,8 +8,11 @@
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <unistd.h>
|
||||
#define PATH_SLASH "\\"
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#define PATH_SLASH "//"
|
||||
#endif // _WIN32
|
||||
|
||||
@@ -18,9 +21,9 @@ typedef std::vector<std::string> string_array;
|
||||
typedef const std::string &refCnstStr;
|
||||
|
||||
static const std::string base64_chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
std::string UrlEncode(const std::string& str);
|
||||
std::string UrlDecode(const std::string& str);
|
||||
@@ -70,11 +73,13 @@ static inline bool strFind(const std::string &str, const std::string &target)
|
||||
return str.find(target) != str.npos;
|
||||
}
|
||||
|
||||
static inline bool startsWith(const std::string &hay, const std::string &needle) {
|
||||
static inline bool startsWith(const std::string &hay, const std::string &needle)
|
||||
{
|
||||
return hay.substr(0, needle.length()) == needle;
|
||||
}
|
||||
|
||||
static inline bool endsWith(const std::string &hay, const std::string &needle) {
|
||||
static inline bool endsWith(const std::string &hay, const std::string &needle)
|
||||
{
|
||||
std::string::size_type hl = hay.length(), nl = needle.length();
|
||||
return hl >= nl && hay.substr(hl - nl, nl) == needle;
|
||||
}
|
||||
@@ -108,15 +113,24 @@ int to_int(const std::string &str, int def_value = 0);
|
||||
#ifndef HAVE_TO_STRING
|
||||
namespace std
|
||||
{
|
||||
template <typename T> std::string to_string(const T& n)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << n;
|
||||
return ss.str();
|
||||
}
|
||||
template <typename T> std::string to_string(const T& n)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << n;
|
||||
return ss.str();
|
||||
}
|
||||
}
|
||||
#endif // HAVE_TO_STRING
|
||||
|
||||
static inline int md(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return mkdir(path);
|
||||
#else
|
||||
return mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void StringToWstring(std::wstring& szDst, const std::string &str);
|
||||
#endif // _WIN32
|
||||
|
||||
+1
-1
@@ -1796,7 +1796,7 @@ std::string netchToSSD(std::vector<nodeInfo> &nodes, std::string &group, std::st
|
||||
const time_t rawtime = to_int(expiry);
|
||||
char buffer[30];
|
||||
struct tm *dt = localtime(&rawtime);
|
||||
strftime(buffer, sizeof(buffer), "%F %R", dt);
|
||||
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M", dt);
|
||||
writer.Key("expiry");
|
||||
writer.String(buffer);
|
||||
}
|
||||
|
||||
+7
-3
@@ -9,6 +9,10 @@
|
||||
#include "misc.h"
|
||||
#include "logger.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define _stat stat
|
||||
#endif // _WIN32
|
||||
|
||||
extern bool print_debug_info;
|
||||
|
||||
//std::string user_agent_str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36";
|
||||
@@ -89,11 +93,11 @@ std::string webGet(std::string url, std::string proxy, std::string &response_hea
|
||||
// cache system
|
||||
if(cache_ttl > 0)
|
||||
{
|
||||
mkdir("cache");
|
||||
md("cache");
|
||||
std::string url_md5 = getMD5(url);
|
||||
std::string path = "cache/" + url_md5;
|
||||
struct _stat result;
|
||||
if(_stat(path.data(), &result) == 0)
|
||||
struct stat result;
|
||||
if(stat(path.data(), &result) == 0)
|
||||
{
|
||||
time_t mtime = result.st_mtime, now = time(NULL);
|
||||
if(difftime(now, mtime) <= cache_ttl)
|
||||
|
||||
Reference in new issue
Block a user