Enhancements

Fix potential crash related to the new file reader.
Fix loading local subscriptions requires token when API mode is disabled.
Add support for parsing Clash Proxy Provider.
Update READMEs.
This commit is contained in:
Tindy X committed 2020-02-22 02:49:41 +08:00
1 parent 0527f1ddd4
commit e3726192dd
5 files changed
+104 -42

No files matched your search

+9 -16
View File
@@ -5,6 +5,7 @@
#include <sstream>
#include <iosfwd>
#include <iostream>
#include <cstdio>
//#include <filesystem>
#include <unistd.h>
@@ -688,10 +689,8 @@ std::string getMD5(const std::string &data)
// TODO: Add preprocessor option to disable (open web service safety)
std::string fileGet(const std::string &path, bool binary, bool scope_limit)
{
std::ifstream infile;
//std::stringstream strstrm;
std::string content;
std::ios::openmode mode = binary ? std::ios::binary : std::ios::in;
const char *mode = binary ? "rb" : "r";
if(scope_limit)
{
@@ -704,20 +703,14 @@ std::string fileGet(const std::string &path, bool binary, bool scope_limit)
#endif // _WIN32
}
infile.open(path, mode);
if(infile)
std::FILE *fp = std::fopen(path.c_str(), mode);
if(fp)
{
//move to a faster method
infile.seekg(0, std::ios::end);
content.resize(infile.tellg());
infile.seekg(0, std::ios::beg);
infile.read(&content[0], content.size());
infile.close();
/*
strstrm << infile.rdbuf();
infile.close();
return strstrm.str();
*/
std::fseek(fp, 0, SEEK_END);
content.resize(std::ftell(fp));
std::rewind(fp);
std::fread(&content[0], 1, content.size(), fp);
std::fclose(fp);
}
return content;
}