diff options
author | Alex Borisov <borisov.alexandr@rambler.ru> | 2011-11-13 14:03:39 +0200 |
---|---|---|
committer | Alex Borisov <borisov.alexandr@rambler.ru> | 2011-11-13 14:03:39 +0200 |
commit | b8a4ef60a8fdde02460d329c8b5caac414c38ebd (patch) | |
tree | f388d41383857e2e89162de18302f672c574000d /client/Config.cpp | |
parent | d3f1d599d4a9d44f48ae91d84618e3cdc4651aa0 (diff) |
style.qss exitstance check. FIX: reading config files issue
Diffstat (limited to 'client/Config.cpp')
-rw-r--r-- | client/Config.cpp | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/client/Config.cpp b/client/Config.cpp index e6174c1..6b1d4f9 100644 --- a/client/Config.cpp +++ b/client/Config.cpp @@ -21,15 +21,15 @@ Config::Config(): StaticProxySpeedLow(50) return; } - string config = ""; - const int str_size = 512; - char str[str_size] = {0}; - while (!configFile.eof()) - { - configFile.read(str, str_size); - config += str; - } - ParseConfig(str); + configFile.seekg (0, ios::end); + int length = configFile.tellg(); + configFile.seekg (0, ios::beg); + char *buffer = new char [length]; + configFile.read (buffer, length); + configFile.close(); + string config = buffer; + ParseConfig(config); + delete[] buffer; } void Config::AcquireConfig() @@ -274,24 +274,22 @@ void Config::ReadGenericProxy() string filname = QCoreApplication::applicationDirPath().toStdString() + "/config/proxy_list.cfg"; - ifstream proxyFile(filname.c_str(), std::ios::in); + ifstream proxyFile(filname.c_str(), std::ios::binary | std::ios::in); if (! proxyFile) { Logger::Error("Can't open file %s\n", filname.c_str()); return; } - string proxies = ""; - const int str_size = 512; - char str[str_size] = {0}; - while (!proxyFile.eof()) - { - proxyFile.read(str, str_size); - proxies += str; - } + proxyFile.seekg (0, ios::end); + int length = proxyFile.tellg(); + proxyFile.seekg (0, ios::beg); + char *buffer = new char [length]; + proxyFile.read (buffer, length); proxyFile.close(); - + string proxies = buffer; ParseGenericProxies(proxies); + delete[] buffer; } /** @@ -310,17 +308,15 @@ void Config::ReadStaticProxy() return; } - string proxies = ""; - const int str_size = 512; - char str[str_size] = {0}; - while (!proxyFile.eof()) - { - proxyFile.read(str, str_size); - proxies += str; - } + proxyFile.seekg (0, ios::end); + int length = proxyFile.tellg(); + proxyFile.seekg (0, ios::beg); + char *buffer = new char [length]; + proxyFile.read (buffer, length); proxyFile.close(); - + string proxies = buffer; ParseStaticPorxies(proxies); + delete[] buffer; } |