Browse Source

Merge pull request #2037 from vovasty/fs_ios_simulator_fix

fix HashedStorage::Init exceptions in ios simulator.
pull/2041/head
orignal 9 months ago committed by GitHub
parent
commit
6432963294
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 21
      libi2pd/FS.cpp

21
libi2pd/FS.cpp

@ -9,6 +9,11 @@ @@ -9,6 +9,11 @@
#include <algorithm>
#include <boost/filesystem.hpp>
#if defined(MAC_OSX)
#include <boost/system/system_error.hpp>
#include <TargetConditionals.h>
#endif
#ifdef _WIN32
#include <shlobj.h>
#include <windows.h>
@ -251,8 +256,22 @@ namespace fs { @@ -251,8 +256,22 @@ namespace fs {
auto p = root + i2p::fs::dirSep + prefix1 + chars[i];
if (boost::filesystem::exists(p))
continue;
if (boost::filesystem::create_directory(p))
#if TARGET_OS_SIMULATOR
// ios simulator fs says it is case sensitive, but it is not
boost::system::error_code ec;
if (boost::filesystem::create_directory(p, ec))
continue;
switch (ec.value()) {
case boost::system::errc::file_exists:
case boost::system::errc::success:
continue;
default:
throw boost::system::system_error( ec, __func__ );
}
#else
if (boost::filesystem::create_directory(p))
continue; /* ^ throws exception on failure */
#endif
return false;
}
return true;

Loading…
Cancel
Save