|
35 | 35 | return error.localizedDescription; |
36 | 36 | } |
37 | 37 |
|
38 | | -static void RLMCheckSkipBackupAttributeToItemAtPath(std::string_view path, bool exclude_from_icloud_backup) { |
39 | | - NSNumber *current; |
40 | | - |
41 | | - [[NSURL fileURLWithPath:@(path.data())] |
42 | | - getResourceValue:¤t |
43 | | - forKey:NSURLIsExcludedFromBackupKey |
44 | | - error:nil]; |
45 | | - |
46 | | - if (current.boolValue != exclude_from_icloud_backup) { |
47 | | - [[NSURL fileURLWithPath:@(path.data())] |
48 | | - setResourceValue:@(exclude_from_icloud_backup) |
49 | | - forKey:NSURLIsExcludedFromBackupKey |
50 | | - error:nil]; |
51 | | - |
52 | | - } |
53 | | -} |
54 | | - |
55 | | -static void RLMCheckSkipBackupAttributeToRealmFilesAtPath(std::string path, bool exclude_from_icloud_backup) { |
56 | | - const std::vector<std::string> extensions = {"", ".lock", ".note", |
57 | | - ".management"}; |
58 | | - |
59 | | - for (const auto& ext : extensions) { |
60 | | - RLMCheckSkipBackupAttributeToItemAtPath(path + ext, exclude_from_icloud_backup); |
61 | | - } |
62 | | -} |
63 | | - |
64 | 38 | static std::string s_default_realm_directory; |
65 | 39 |
|
66 | 40 | namespace realm { |
@@ -184,15 +158,28 @@ static void RLMCheckSkipBackupAttributeToRealmFilesAtPath(std::string path, bool |
184 | 158 | } |
185 | 159 | } |
186 | 160 |
|
187 | | -void JsPlatformHelpers::after_realm_open(const SharedRealm realm, bool exclude_from_icloud_backup) { |
188 | | - RLMCheckSkipBackupAttributeToRealmFilesAtPath(realm->config().path, exclude_from_icloud_backup); |
189 | | -} |
190 | | - |
191 | 161 | void JsPlatformHelpers::remove_directory(const std::string &path) |
192 | 162 | { |
193 | 163 | remove_file(path); // works for directories too |
194 | 164 | } |
195 | 165 |
|
| 166 | +void JsPlatformHelpers::exclude_from_icloud_backup(const std::string& path, bool value) { |
| 167 | + NSNumber *current; |
| 168 | + |
| 169 | + [[NSURL fileURLWithPath:@(path.data())] |
| 170 | + getResourceValue:¤t |
| 171 | + forKey:NSURLIsExcludedFromBackupKey |
| 172 | + error:nil]; |
| 173 | + |
| 174 | + if (current.boolValue != value) { |
| 175 | + [[NSURL fileURLWithPath:@(path.data())] |
| 176 | + setResourceValue:@(value) |
| 177 | + forKey:NSURLIsExcludedFromBackupKey |
| 178 | + error:nil]; |
| 179 | + |
| 180 | + } |
| 181 | +} |
| 182 | + |
196 | 183 | void JsPlatformHelpers::print(const char *fmt, ...) { |
197 | 184 | va_list vl; |
198 | 185 | va_start(vl, fmt); |
|
0 commit comments