KMServicesCloudFile.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // KMServicesFiles.m
  3. // PDF Reader
  4. //
  5. // Created by 丁林圭 on 2020/7/8.
  6. // Copyright © 2020 Kdan Mobile. All rights reserved.
  7. //
  8. #import "KMServicesCloudFile.h"
  9. #pragma mark - KMGoogleDriveUserMetadata
  10. @implementation KMGoogleDriveUserMetadata
  11. - (void)dealloc {}
  12. @end
  13. #pragma mark - KMDropboxUserMetadata
  14. @implementation KMDropboxUserMetadata
  15. - (void)dealloc {}
  16. @end
  17. #pragma mark - KMDropboxErrorMetadata
  18. @implementation KMDropboxErrorMetadata
  19. - (void)dealloc {}
  20. @end
  21. #pragma mark - KMServicesFile
  22. @implementation KMServicesCloudFile
  23. - (void)dealloc {}
  24. - (NSString *)fileSizeString
  25. {
  26. float fileSize = self.fileSize / 1024;
  27. float size = fileSize >= 1024 ?(fileSize < 1048576 ? fileSize/1024.0 : fileSize/1048576.0) : fileSize;
  28. char unit = fileSize >= 1024 ? (fileSize < 1048576 ? 'M':'G'):'K';
  29. return [NSString stringWithFormat:@"%0.1f%c", size, unit]?:@"";
  30. }
  31. - (NSString *)fileModiDateString
  32. {
  33. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  34. [dateFormatter setDateFormat:@"yyyy/MM/dd hh:mm:ss"];
  35. NSString * dateString = [dateFormatter stringFromDate:self.fileModiDate];
  36. return dateString;
  37. }
  38. - (NSString *)file_type {
  39. if (self.mimeType) {
  40. return self.mimeType;
  41. }
  42. return @"";
  43. }
  44. - (NSComparisonResult)nameCompare:(KMServicesCloudFile *)item {
  45. return [self.fileName caseInsensitiveCompare:item.fileName];
  46. }
  47. - (NSComparisonResult)dateCompare:(KMServicesCloudFile *)item {
  48. return [self.fileModiDate compare:item.fileModiDate];
  49. }
  50. //#define IntCompare(a, b) (a!=b ? a>b ? NSOrderedDescending : NSOrderedAscending : NSOrderedSame)
  51. //- (NSComparisonResult)sizeCompare:(KMServicesCloudFile *)item {
  52. // return self.isDirectory ? IntCompare(self.filesCount, item.filesCount) : IntCompare(self.fileSize, item.fileSize);
  53. //}
  54. @end