diff --git a/platform/http_request.cpp b/platform/http_request.cpp index a8f49ff7c9..20f6d7037d 100644 --- a/platform/http_request.cpp +++ b/platform/http_request.cpp @@ -20,53 +20,6 @@ #include "3party/Alohalytics/src/alohalytics.h" -#ifdef OMIM_OS_IPHONE - -#include -#include -#include -// declaration is taken from NSObjCRuntime.h to avoid including of ObjC code -extern "C" double NSFoundationVersionNumber; - -#endif - -void DisableBackupForFile(string const & filePath) -{ -#ifdef OMIM_OS_IPHONE - // We need to disable iCloud backup for downloaded files. - // This is the reason for rejecting from the AppStore - // https://developer.apple.com/library/iOS/qa/qa1719/_index.html - - // value is taken from NSObjCRuntime.h to avoid including of ObjC code - #define NSFoundationVersionNumber_iOS_5_1 890.10 - if (NSFoundationVersionNumber >= NSFoundationVersionNumber_iOS_5_1) - { - CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, - reinterpret_cast(filePath.c_str()), - filePath.size(), - 0); - CFErrorRef err; - signed char valueRaw = 1; // BOOL YES - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberCharType, &valueRaw); - if (!CFURLSetResourcePropertyForKey(url, kCFURLIsExcludedFromBackupKey, value, &err)) - { - LOG(LWARNING, ("Error while disabling iCloud backup for file", filePath)); - } - CFRelease(value); - CFRelease(url); - } - else - { - static char const * attrName = "com.apple.MobileBackup"; - u_int8_t attrValue = 1; - const int result = setxattr(filePath.c_str(), attrName, &attrValue, sizeof(attrValue), 0, 0); - if (result != 0) - LOG(LWARNING, ("Error while disabling iCloud backup for file", filePath)); - } -#endif -} - - class HttpThread; namespace downloader @@ -296,7 +249,7 @@ class FileHttpRequest : public HttpRequest, public IHttpThreadCallback CHECK(my::RenameFileX(m_filePath + DOWNLOADING_FILE_EXTENSION, m_filePath), (m_filePath, strerror(errno))); - DisableBackupForFile(m_filePath); + Platform::DisableBackupForFile(m_filePath); } // 4. Finish downloading. @@ -350,11 +303,7 @@ public: // Assign here, because previous functions can throw an exception. m_writer.swap(writer); - -#ifdef OMIM_OS_IPHONE - DisableBackupForFile(filePath + DOWNLOADING_FILE_EXTENSION); -#endif - + Platform::DisableBackupForFile(filePath + DOWNLOADING_FILE_EXTENSION); (void)StartThreads(); } diff --git a/platform/platform.hpp b/platform/platform.hpp index a0b58bb86f..efdc6f8e31 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -109,6 +109,7 @@ public: virtual ~Platform() = default; static bool IsFileExistsByFullPath(string const & filePath); + static void DisableBackupForFile(string const & filePath); /// @return true if we can create custom texture allocator in drape static bool IsCustomTextureAllocatorSupported(); diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm index 4654fc3a39..1ce7f8764d 100644 --- a/platform/platform_ios.mm +++ b/platform/platform_ios.mm @@ -19,11 +19,14 @@ #include #include #include +#include #import "iphone/Maps/Common/MWMCommon.h" #import "3party/Alohalytics/src/alohalytics_objc.h" +#import +#import #import #import @@ -62,6 +65,26 @@ Platform::Platform() // static bool Platform::IsCustomTextureAllocatorSupported() { return !isIOS8; } +//static +void Platform::DisableBackupForFile(string const & filePath) +{ + // We need to disable iCloud backup for downloaded files. + // This is the reason for rejecting from the AppStore + // https://developer.apple.com/library/iOS/qa/qa1719/_index.html + CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, + reinterpret_cast(filePath.c_str()), + filePath.size(), + 0); + CFErrorRef err; + BOOL valueRaw = YES; + CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberCharType, &valueRaw); + if (!CFURLSetResourcePropertyForKey(url, kCFURLIsExcludedFromBackupKey, value, &err)) + NSLog(@"Error while disabling iCloud backup for file: %s", filePath.c_str()); + + CFRelease(value); + CFRelease(url); +} + // static Platform::EError Platform::MkDir(string const & dirName) { diff --git a/platform/platform_unix_impl.cpp b/platform/platform_unix_impl.cpp index 34b91fb71a..5e3042d41c 100644 --- a/platform/platform_unix_impl.cpp +++ b/platform/platform_unix_impl.cpp @@ -152,6 +152,9 @@ bool Platform::IsFileExistsByFullPath(string const & filePath) return stat(filePath.c_str(), &s) == 0; } +//static +void Platform::DisableBackupForFile(string const & filePath) {} + // static bool Platform::IsCustomTextureAllocatorSupported() { return true; } diff --git a/platform/platform_win.cpp b/platform/platform_win.cpp index 8152d5b7fc..03eae8d4e2 100644 --- a/platform/platform_win.cpp +++ b/platform/platform_win.cpp @@ -95,6 +95,9 @@ bool Platform::IsFileExistsByFullPath(string const & filePath) return ::GetFileAttributesA(filePath.c_str()) != INVALID_FILE_ATTRIBUTES; } +//static +void Platform::DisableBackupForFile(string const & filePath) {} + // static Platform::EError Platform::RmDir(string const & dirName) { diff --git a/storage/storage.cpp b/storage/storage.cpp index 2b85888e42..1c2c75f8be 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -1434,8 +1434,10 @@ void Storage::ApplyDiff(TCountryId const & countryId, functionGetPath(MapOptions::Map)); + } fn(result); }); });