Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / ios / chrome / browser / file_metadata_util.mm
blob9aaac43c632398c55bd2b2975b094eb801cd77f9
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
3 // found in the LICENSE file.
5 #include "ios/chrome/browser/file_metadata_util.h"
7 #import <Foundation/Foundation.h>
9 #include "base/logging.h"
10 #include "base/strings/sys_string_conversions.h"
11 #include "base/threading/thread_restrictions.h"
13 namespace file_metadata_util {
15 void AddSkipSystemBackupAttributeToItem(const base::FilePath& path) {
16   base::ThreadRestrictions::AssertIOAllowed();
18   NSURL* file_url =
19       [NSURL fileURLWithPath:base::SysUTF8ToNSString(path.value())];
20   DCHECK([[NSFileManager defaultManager] fileExistsAtPath:file_url.path]);
22   NSError* error = nil;
23   BOOL success = [file_url setResourceValue:@YES
24                                      forKey:NSURLIsExcludedFromBackupKey
25                                       error:&error];
26   if (!success) {
27     LOG(ERROR) << [[error description] UTF8String];
28   }
31 }  // namespace file_metadata_util