CCAdvanced.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. //
  2. // CCManageHelp.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 06/11/15.
  6. // Copyright (c) 2014 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "CCAdvanced.h"
  24. #import "CCUtility.h"
  25. #import "AppDelegate.h"
  26. @interface CCAdvanced ()
  27. @end
  28. @implementation CCAdvanced
  29. -(id)init
  30. {
  31. XLFormDescriptor *form ;
  32. XLFormSectionDescriptor *section;
  33. XLFormRowDescriptor *row;
  34. form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_advanced_", nil)];
  35. // Section ACTIVITY -------------------------------------------------
  36. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_activity_", nil)];
  37. [form addFormSection:section];
  38. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"activityVerboseHigh" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_help_activity_verbose_", nil)];
  39. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  40. [row.cellConfig setObject:[UIImage imageNamed:image_settingsActivityHigh] forKey:@"imageView.image"];
  41. if ([CCUtility getActivityVerboseHigh]) row.value = @"1";
  42. else row.value = @"0";
  43. [section addFormRow:row];
  44. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sendMailActivity" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_help_activity_mail_", nil)];
  45. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  46. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  47. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  48. [row.cellConfig setObject:[UIImage imageNamed:image_settingsSendActivity] forKey:@"imageView.image"];
  49. row.action.formSelector = @selector(sendMail:);
  50. [section addFormRow:row];
  51. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"clearActivityLog" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_help_activity_clear_", nil)];
  52. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  53. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  54. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  55. [row.cellConfig setObject:[UIImage imageNamed:image_settingsClearActivity] forKey:@"imageView.image"];
  56. row.action.formSelector = @selector(clearActivity:);
  57. [section addFormRow:row];
  58. // Section CLEAR CACHE -------------------------------------------------
  59. section = [XLFormSectionDescriptor formSection];
  60. [form addFormSection:section];
  61. // Clear cache
  62. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeracache" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_cache_no_size_", nil)];
  63. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  64. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  65. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  66. [row.cellConfig setObject:[UIImage imageNamed:image_settingsClearCache] forKey:@"imageView.image"];
  67. row.action.formSelector = @selector(clearCache:);
  68. [section addFormRow:row];
  69. // Section EXIT --------------------------------------------------------
  70. section = [XLFormSectionDescriptor formSection];
  71. [form addFormSection:section];
  72. // Exit
  73. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"esci" rowType:XLFormRowDescriptorTypeButton title:[CCUtility localizableBrand:@"_exit_" table:nil]];
  74. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  75. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  76. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  77. [row.cellConfig setObject:[UIImage imageNamed:image_settingsExit] forKey:@"imageView.image"];
  78. row.action.formSelector = @selector(exitNextcloud:);
  79. [section addFormRow:row];
  80. return [super initWithForm:form];
  81. }
  82. // Apparirà
  83. - (void)viewWillAppear:(BOOL)animated
  84. {
  85. [super viewWillAppear:animated];
  86. // Color
  87. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
  88. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  89. [self recalculateSize];
  90. }
  91. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  92. {
  93. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  94. if ([rowDescriptor.tag isEqualToString:@"activityVerboseHigh"]) {
  95. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  96. [CCUtility setActivityVerboseHigh:true];
  97. } else {
  98. [CCUtility setActivityVerboseHigh:false];
  99. }
  100. // Clear Date read Activity for force reload datasource
  101. app.activeActivity.storeDateFirstActivity = nil;
  102. }
  103. }
  104. #pragma --------------------------------------------------------------------------------------------
  105. #pragma mark === Mail ===
  106. #pragma --------------------------------------------------------------------------------------------
  107. - (void) mailComposeController:(MFMailComposeViewController *)vc didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
  108. {
  109. switch (result)
  110. {
  111. case MFMailComposeResultCancelled:
  112. [app messageNotification:@"_info_" description:@"_mail_deleted_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  113. break;
  114. case MFMailComposeResultSaved:
  115. [app messageNotification:@"_info_" description:@"_mail_saved_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  116. break;
  117. case MFMailComposeResultSent:
  118. [app messageNotification:@"_info_" description:@"_mail_sent_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  119. break;
  120. case MFMailComposeResultFailed: {
  121. NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"_mail_failure_", nil), [error localizedDescription]];
  122. [app messageNotification:@"_error_" description:msg visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
  123. }
  124. break;
  125. default:
  126. break;
  127. }
  128. // Close the Mail Interface
  129. [self dismissViewControllerAnimated:YES completion:NULL];
  130. }
  131. - (void)sendMail:(XLFormRowDescriptor *)sender
  132. {
  133. [self deselectFormRow:sender];
  134. // Email Subject
  135. NSString *emailTitle = NSLocalizedString(@"_information_req_", nil);
  136. // Email Content
  137. NSString *messageBody;
  138. // File Attachment
  139. NSString *fileAttachment = @"";
  140. // Email Recipents
  141. NSArray *toRecipents;
  142. NSArray *activities = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"((account == %@) || (account == ''))", app.activeAccount]];
  143. if ([activities count] == 0) {
  144. [app messageNotification:@"_info_" description:@"No activity found" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo];
  145. return;
  146. }
  147. for (TableActivity *activity in activities) {
  148. NSString *date, *type, *actionFile, *note;
  149. date = [[NSDateFormatter localizedStringFromDate:activity.date dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterMediumStyle] stringByPaddingToLength:22 withString:@" " startingAtIndex:0];
  150. if ([activity.type isEqual: k_activityTypeInfo]) type = @"Info ";
  151. if ([activity.type isEqual: k_activityTypeSuccess]) type = @"Success";
  152. if ([activity.type isEqual: k_activityTypeFailure]) type = @"Failure";
  153. actionFile = [[NSString stringWithFormat:@"%@ %@", activity.action, activity.file] stringByPaddingToLength:100 withString:@" " startingAtIndex:0];
  154. if (activity.idActivity == 0) note = [NSString stringWithFormat:@"%@ Selector: %@", activity.note, activity.selector];
  155. else note = activity.note;
  156. note = [note stringByPaddingToLength:200 withString:@" " startingAtIndex:0];
  157. fileAttachment = [fileAttachment stringByAppendingString:[NSString stringWithFormat:@"| %@ | %@ | %@ | %@ |\n", date, type, actionFile, note]];
  158. }
  159. messageBody = [NSString stringWithFormat:@"\n\n\n%@ Version %@ (%@)", k_brand,[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  160. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  161. NSString *documentsDirectory = [paths objectAtIndex:0];
  162. NSError *error;
  163. if ([fileAttachment writeToFile:[documentsDirectory stringByAppendingPathComponent:@"activity.txt"] atomically:YES encoding:NSUTF8StringEncoding error:&error]) {
  164. toRecipents = [NSArray arrayWithObject:k_mailMe];
  165. MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
  166. mc.mailComposeDelegate = self;
  167. [mc setSubject:emailTitle];
  168. [mc setMessageBody:messageBody isHTML:NO];
  169. [mc setToRecipients:toRecipents];
  170. NSData *noteData = [NSData dataWithContentsOfFile:[documentsDirectory stringByAppendingPathComponent:@"activity.txt"]];
  171. [mc addAttachmentData:noteData mimeType:@"text/plain" fileName:@"activity.txt"];
  172. // Present mail view controller on screen
  173. [self presentViewController:mc animated:YES completion:NULL];
  174. } else {
  175. [app messageNotification:@"_error_" description:@"Impossible create file body" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
  176. }
  177. }
  178. #pragma --------------------------------------------------------------------------------------------
  179. #pragma mark === Clear Activity ===
  180. #pragma --------------------------------------------------------------------------------------------
  181. - (void)clearActivity:(XLFormRowDescriptor *)sender
  182. {
  183. [self deselectFormRow:sender];
  184. [CCCoreData flushTableActivityAccount:app.activeAccount];
  185. [app.activeActivity reloadDatasource];
  186. }
  187. #pragma --------------------------------------------------------------------------------------------
  188. #pragma mark === Clear Cache ===
  189. #pragma --------------------------------------------------------------------------------------------
  190. - (void)clearCache:(XLFormRowDescriptor *)sender
  191. {
  192. [self deselectFormRow:sender];
  193. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  194. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  195. [self.hud visibleHudTitle:NSLocalizedString(@"_remove_cache_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
  196. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  197. [app cancelAllOperations];
  198. [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
  199. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  200. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  201. [CCCoreData flushTableAutomaticUploadAccount:app.activeAccount selector:nil];
  202. [CCCoreData flushTableDirectoryAccount:app.activeAccount];
  203. [CCCoreData flushTableLocalFileAccount:app.activeAccount];
  204. [CCCoreData flushTableMetadataAccount:app.activeAccount];
  205. [CCCoreData flushTableActivityAccount:app.activeAccount];
  206. [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl];
  207. [self emptyLocalDirectory];
  208. NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
  209. for (NSString *file in tmpDirectory)
  210. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
  211. [self recalculateSize];
  212. // Inizialized home
  213. [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
  214. [self.hud hideHud];
  215. });
  216. }]];
  217. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  218. }]];
  219. //if iPhone
  220. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  221. [self presentViewController:alertController animated:YES completion:nil];
  222. }
  223. //if iPad
  224. else {
  225. // Change Rect to position Popover
  226. UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:alertController];
  227. [popup presentPopoverFromRect:[self.tableView rectForRowAtIndexPath:[self.form indexPathOfFormRow:sender]] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  228. }
  229. }
  230. - (void)recalculateSize
  231. {
  232. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  233. self.form.delegate = nil;
  234. XLFormRowDescriptor *rowAzzeraCache = [self.form formRowWithTag:@"azzeracache"];
  235. NSString *size = [CCUtility transformedSize:[[self getUserDirectorySize] longValue]];
  236. rowAzzeraCache.title = [NSString stringWithFormat:NSLocalizedString(@"_clear_cache_", nil), size];
  237. //rowAzzeraCache.title = NSLocalizedString(@"_clear_cache_no_size_", nil);
  238. [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  239. self.form.delegate = self;
  240. });
  241. }
  242. #pragma --------------------------------------------------------------------------------------------
  243. #pragma mark == Exit Nextcloud ==
  244. #pragma --------------------------------------------------------------------------------------------
  245. - (void)exitNextcloud:(XLFormRowDescriptor *)sender
  246. {
  247. [self deselectFormRow:sender];
  248. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:[CCUtility localizableBrand:@"_want_exit_" table:nil] preferredStyle:UIAlertControllerStyleActionSheet];
  249. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  250. [self.hud visibleIndeterminateHud];
  251. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  252. [app cancelAllOperations];
  253. [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
  254. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  255. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  256. [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
  257. [CCCoreData flushAllDatabase];
  258. [CCUtility deleteAllChainStore];
  259. [self emptyDocumentsDirectory];
  260. [self emptyLibraryDirectory];
  261. [self emptyGroupApplicationSupport];
  262. NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
  263. for (NSString *file in tmpDirectory)
  264. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
  265. [self.hud hideHud];
  266. exit(0);
  267. });
  268. }]];
  269. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  270. }]];
  271. //if iPhone
  272. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  273. [self presentViewController:alertController animated:YES completion:nil];
  274. }
  275. //if iPad
  276. else {
  277. // Change Rect to position Popover
  278. UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:alertController];
  279. [popup presentPopoverFromRect:[self.tableView rectForRowAtIndexPath:[self.form indexPathOfFormRow:sender]] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  280. }
  281. }
  282. #pragma --------------------------------------------------------------------------------------------
  283. #pragma mark == Utility ==
  284. #pragma --------------------------------------------------------------------------------------------
  285. - (void)emptyGroupApplicationSupport
  286. {
  287. NSString *file;
  288. NSURL *dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:k_capabilitiesGroups];
  289. NSString *dirIniziale = [[dirGroup URLByAppendingPathComponent:appApplicationSupport] path];
  290. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  291. while (file = [enumerator nextObject])
  292. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  293. }
  294. - (void)emptyLibraryDirectory
  295. {
  296. NSString *file;
  297. NSString *dirIniziale;
  298. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
  299. dirIniziale = [paths objectAtIndex:0];
  300. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  301. while (file = [enumerator nextObject])
  302. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  303. }
  304. - (void)emptyDocumentsDirectory
  305. {
  306. NSString *file;
  307. NSString *dirIniziale;
  308. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  309. dirIniziale = [paths objectAtIndex:0];
  310. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  311. while (file = [enumerator nextObject])
  312. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  313. }
  314. - (void)emptyUserDirectoryUser:(NSString *)user url:(NSString *)url
  315. {
  316. NSString *file;
  317. NSString *dirIniziale;
  318. dirIniziale = [CCUtility getDirectoryActiveUser:user activeUrl:url];
  319. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  320. while (file = [enumerator nextObject]) {
  321. NSString *ext = [[file pathExtension] lowercaseString];
  322. // Do not remove ICO
  323. if ([ext isEqualToString:@"ico"])
  324. continue;
  325. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  326. }
  327. }
  328. - (void)emptyLocalDirectory
  329. {
  330. NSString *file;
  331. NSString *dirIniziale;
  332. dirIniziale = [CCUtility getDirectoryLocal];
  333. NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
  334. while (file = [enumerator nextObject])
  335. [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
  336. }
  337. - (NSNumber *)getUserDirectorySize
  338. {
  339. NSString *directoryUser = [CCUtility getDirectoryActiveUser:app.activeUser activeUrl:app.activeUrl];
  340. NSURL *directoryURL = [NSURL fileURLWithPath:directoryUser];
  341. unsigned long long count = 0;
  342. NSNumber *value = nil;
  343. if (! directoryURL) return 0;
  344. // Get dimension Document
  345. for (NSURL *url in [[NSFileManager defaultManager] enumeratorAtURL:directoryURL includingPropertiesForKeys:@[NSURLFileSizeKey] options:0 errorHandler:NULL]) {
  346. if ([url getResourceValue:&value forKey:NSURLFileSizeKey error:nil]) {
  347. count += [value longLongValue];
  348. } else {
  349. return nil;
  350. }
  351. }
  352. return @(count);
  353. }
  354. @end