OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ios/chrome/browser/file_metadata_util.h" | 5 #include "ios/chrome/browser/file_metadata_util.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
12 | 12 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." |
| 15 #endif |
| 16 |
13 void SetSkipSystemBackupAttributeToItem(const base::FilePath& path, | 17 void SetSkipSystemBackupAttributeToItem(const base::FilePath& path, |
14 bool skip_system_backup) { | 18 bool skip_system_backup) { |
15 base::ThreadRestrictions::AssertIOAllowed(); | 19 base::ThreadRestrictions::AssertIOAllowed(); |
16 | 20 |
17 NSURL* file_url = | 21 NSURL* file_url = |
18 [NSURL fileURLWithPath:base::SysUTF8ToNSString(path.value())]; | 22 [NSURL fileURLWithPath:base::SysUTF8ToNSString(path.value())]; |
19 DCHECK([[NSFileManager defaultManager] fileExistsAtPath:file_url.path]); | 23 DCHECK([[NSFileManager defaultManager] fileExistsAtPath:file_url.path]); |
20 | 24 |
21 NSError* error = nil; | 25 NSError* error = nil; |
22 BOOL success = [file_url setResourceValue:(skip_system_backup ? @YES : @NO) | 26 BOOL success = [file_url setResourceValue:(skip_system_backup ? @YES : @NO) |
23 forKey:NSURLIsExcludedFromBackupKey | 27 forKey:NSURLIsExcludedFromBackupKey |
24 error:&error]; | 28 error:&error]; |
25 if (!success) { | 29 if (!success) { |
26 LOG(ERROR) << [[error description] UTF8String]; | 30 LOG(ERROR) << [[error description] UTF8String]; |
27 } | 31 } |
28 } | 32 } |
29 | 33 |
OLD | NEW |