|
|
@ -54,7 +54,11 @@ namespace fs { |
|
|
|
|
|
|
|
|
|
|
|
const std::string GetUTF8DataDir () { |
|
|
|
const std::string GetUTF8DataDir () { |
|
|
|
#ifdef _WIN32 |
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
|
|
#if (BOOST_VERSION >= 108500) |
|
|
|
|
|
|
|
boost::filesystem::path path (dataDir); |
|
|
|
|
|
|
|
#else |
|
|
|
boost::filesystem::wpath path (dataDir); |
|
|
|
boost::filesystem::wpath path (dataDir); |
|
|
|
|
|
|
|
#endif |
|
|
|
auto loc = boost::filesystem::path::imbue(std::locale( std::locale(), new std::codecvt_utf8_utf16<wchar_t>() ) ); // convert path to UTF-8
|
|
|
|
auto loc = boost::filesystem::path::imbue(std::locale( std::locale(), new std::codecvt_utf8_utf16<wchar_t>() ) ); // convert path to UTF-8
|
|
|
|
auto dataDirUTF8 = path.string(); |
|
|
|
auto dataDirUTF8 = path.string(); |
|
|
|
boost::filesystem::path::imbue(loc); // Return locale settings back
|
|
|
|
boost::filesystem::path::imbue(loc); // Return locale settings back
|
|
|
@ -87,7 +91,11 @@ namespace fs { |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#if (BOOST_VERSION >= 108500) |
|
|
|
|
|
|
|
dataDir = boost::filesystem::path(commonAppData).string() + "\\" + appName; |
|
|
|
|
|
|
|
#else |
|
|
|
dataDir = boost::filesystem::wpath(commonAppData).string() + "\\" + appName; |
|
|
|
dataDir = boost::filesystem::wpath(commonAppData).string() + "\\" + appName; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
dataDir = "/var/lib/" + appName; |
|
|
|
dataDir = "/var/lib/" + appName; |
|
|
@ -112,7 +120,11 @@ namespace fs { |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#if (BOOST_VERSION >= 108500) |
|
|
|
|
|
|
|
auto execPath = boost::filesystem::path(localAppData).parent_path(); |
|
|
|
|
|
|
|
#else |
|
|
|
auto execPath = boost::filesystem::wpath(localAppData).parent_path(); |
|
|
|
auto execPath = boost::filesystem::wpath(localAppData).parent_path(); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// if config file exists in .exe's folder use it
|
|
|
|
// if config file exists in .exe's folder use it
|
|
|
|
if(boost::filesystem::exists(execPath/"i2pd.conf")) // TODO: magic string
|
|
|
|
if(boost::filesystem::exists(execPath/"i2pd.conf")) // TODO: magic string
|
|
|
@ -131,7 +143,11 @@ namespace fs { |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#if (BOOST_VERSION >= 108500) |
|
|
|
|
|
|
|
dataDir = boost::filesystem::path(localAppData).string() + "\\" + appName; |
|
|
|
|
|
|
|
#else |
|
|
|
dataDir = boost::filesystem::wpath(localAppData).string() + "\\" + appName; |
|
|
|
dataDir = boost::filesystem::wpath(localAppData).string() + "\\" + appName; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -257,19 +273,19 @@ namespace fs { |
|
|
|
if (boost::filesystem::exists(p)) |
|
|
|
if (boost::filesystem::exists(p)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
#if TARGET_OS_SIMULATOR |
|
|
|
#if TARGET_OS_SIMULATOR |
|
|
|
// ios simulator fs says it is case sensitive, but it is not
|
|
|
|
// ios simulator fs says it is case sensitive, but it is not
|
|
|
|
boost::system::error_code ec; |
|
|
|
boost::system::error_code ec; |
|
|
|
if (boost::filesystem::create_directory(p, ec)) |
|
|
|
if (boost::filesystem::create_directory(p, ec)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
switch (ec.value()) { |
|
|
|
switch (ec.value()) { |
|
|
|
case boost::system::errc::file_exists: |
|
|
|
case boost::system::errc::file_exists: |
|
|
|
case boost::system::errc::success: |
|
|
|
case boost::system::errc::success: |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
default: |
|
|
|
default: |
|
|
|
throw boost::system::system_error( ec, __func__ ); |
|
|
|
throw boost::system::system_error( ec, __func__ ); |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
if (boost::filesystem::create_directory(p)) |
|
|
|
if (boost::filesystem::create_directory(p)) |
|
|
|
continue; /* ^ throws exception on failure */ |
|
|
|
continue; /* ^ throws exception on failure */ |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
return false; |
|
|
|
return false; |
|
|
|