From 51446f032477cacc4d6b3be25ee6abab746b50ab Mon Sep 17 00:00:00 2001 From: Vlad Solomenchuk Date: Fri, 8 Mar 2024 10:23:51 -0800 Subject: [PATCH 1/2] fix FS::HashedStorage::Init exceptions in ios simulator. --- libi2pd/FS.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libi2pd/FS.cpp b/libi2pd/FS.cpp index d38bcc2f..a02c0818 100644 --- a/libi2pd/FS.cpp +++ b/libi2pd/FS.cpp @@ -9,6 +9,11 @@ #include #include +#if defined(MAC_OSX) +#include +#include +#endif + #ifdef _WIN32 #include #include @@ -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)) +#ifdef 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; From 59beb5e4e48fa0ae5d8437be581017f6d21227b8 Mon Sep 17 00:00:00 2001 From: Vlad Solomenchuk Date: Mon, 11 Mar 2024 11:29:41 -0700 Subject: [PATCH 2/2] fix TARGET_OS_SIMULATOR check --- libi2pd/FS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libi2pd/FS.cpp b/libi2pd/FS.cpp index a02c0818..4d48fc47 100644 --- a/libi2pd/FS.cpp +++ b/libi2pd/FS.cpp @@ -256,7 +256,7 @@ namespace fs { auto p = root + i2p::fs::dirSep + prefix1 + chars[i]; if (boost::filesystem::exists(p)) continue; -#ifdef TARGET_OS_SIMULATOR +#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))