Fixed: failed open default config file if path contains non English characters.
This commit is contained in:
parent
ad0d876b18
commit
1b0ddae4eb
4 changed files with 50 additions and 33 deletions
|
@ -22,7 +22,40 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
||||
char *Platform::m_userAgent = nullptr;
|
||||
char *Platform::m_defaultConfigName = nullptr;
|
||||
char *Platform::m_userAgent = nullptr;
|
||||
|
||||
|
||||
const char *Platform::defaultConfigName()
|
||||
{
|
||||
size_t size = 520;
|
||||
|
||||
if (m_defaultConfigName == nullptr) {
|
||||
m_defaultConfigName = new char[size];
|
||||
}
|
||||
|
||||
if (uv_exepath(m_defaultConfigName, &size) < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (size < 500) {
|
||||
# ifdef WIN32
|
||||
char *p = strrchr(m_defaultConfigName, '\\');
|
||||
# else
|
||||
char *p = strrchr(m_defaultConfigName, '/');
|
||||
# endif
|
||||
|
||||
if (p) {
|
||||
strcpy(p + 1, "config.json");
|
||||
return m_defaultConfigName;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue