diff options
author | VladiMihaylenko <vxmihaylenko@gmail.com> | 2017-10-19 15:07:32 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2017-11-09 11:10:08 +0300 |
commit | f63159e87c149e8b6c7fdb68eb04253f81ac1a49 (patch) | |
tree | e1462124b0cd6a09cc9f39dada4ec9bc4a540092 /platform | |
parent | 465316b7e800d57c73de62bcae1ae8e350c3b6dc (diff) |
Disable backup for mwm after diff was applied.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/http_request.cpp | 55 | ||||
-rw-r--r-- | platform/platform.hpp | 1 | ||||
-rw-r--r-- | platform/platform_ios.mm | 23 | ||||
-rw-r--r-- | platform/platform_unix_impl.cpp | 3 | ||||
-rw-r--r-- | platform/platform_win.cpp | 3 |
5 files changed, 32 insertions, 53 deletions
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 <sys/xattr.h> -#include <CoreFoundation/CoreFoundation.h> -#include <CoreFoundation/CFURL.h> -// 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<unsigned char const *>(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 <sys/socket.h> #include <sys/stat.h> #include <sys/types.h> +#include <sys/xattr.h> #import "iphone/Maps/Common/MWMCommon.h" #import "3party/Alohalytics/src/alohalytics_objc.h" +#import <CoreFoundation/CFURL.h> +#import <CoreFoundation/CoreFoundation.h> #import <SystemConfiguration/SystemConfiguration.h> #import <netinet/in.h> @@ -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<unsigned char const *>(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) { |