CCUtility.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // CCUtility.h
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 02/02/16.
  6. // Copyright (c) 2016 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  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 <Foundation/Foundation.h>
  24. #import <MobileCoreServices/MobileCoreServices.h>
  25. #import <sys/utsname.h>
  26. #import <sys/sysctl.h>
  27. #import <AssetsLibrary/AssetsLibrary.h>
  28. #import <MessageUI/MessageUI.h>
  29. #import <Photos/Photos.h>
  30. #import <PDFKit/PDFKit.h>
  31. @class tableMetadata;
  32. @interface CCUtility : NSObject
  33. + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
  34. + (NSString *)dateDiff:(NSDate *)convertedDate;
  35. + (NSString *)transformedSize:(int64_t)value;
  36. + (NSString *)removeForbiddenCharactersServer:(NSString *)fileName;
  37. + (NSString *)removeForbiddenCharactersFileSystem:(NSString *)fileName;
  38. + (NSString *)stringAppendServerUrl:(NSString *)serverUrl addFileName:(NSString *)addFileName;
  39. + (NSString *)createFileNameDate:(NSString *)fileName extension:(NSString *)extension;
  40. + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fileType:(PHAssetMediaType)fileType keyFileName:(NSString *)keyFileName keyFileNameType:(NSString *)keyFileNameType keyFileNameOriginal:(NSString *)keyFileNameOriginal forcedNewFileName:(BOOL)forcedNewFileName;
  41. + (void)createDirectoryStandard;
  42. + (NSString *)getDirectoryProviderStorage;
  43. + (NSString *)getDirectoryProviderStorageOcId:(NSString *)ocId;
  44. + (NSString *)getDirectoryProviderStorageOcId:(NSString *)ocId fileNameView:(NSString *)fileNameView;
  45. + (NSString *)getDirectoryProviderStorageIconOcId:(NSString *)ocId etag:(NSString *)etag;
  46. + (NSString *)getDirectoryProviderStoragePreviewOcId:(NSString *)ocId etag:(NSString *)etag;
  47. + (BOOL)fileProviderStorageExists:(tableMetadata *)metadata;
  48. + (int64_t)fileProviderStorageSize:(NSString *)ocId fileNameView:(NSString *)fileNameView;
  49. + (BOOL)fileProviderStoragePreviewIconExists:(NSString *)ocId etag:(NSString *)etag;
  50. + (void)removeGroupApplicationSupport;
  51. + (void)removeGroupLibraryDirectory;
  52. + (void)removeGroupDirectoryProviderStorage;
  53. + (void)removeDocumentsDirectory;
  54. + (void)removeTemporaryDirectory;
  55. + (void)emptyTemporaryDirectory;
  56. + (NSString *)getTitleSectionDate:(NSDate *)date;
  57. + (void)moveFileAtPath:(NSString *)atPath toPath:(NSString *)toPath;
  58. + (void)copyFileAtPath:(NSString *)atPath toPath:(NSString *)toPath;
  59. + (void)removeFileAtPath:(NSString *)atPath;
  60. + (void)createDirectoryAtPath:(NSString *)atPath;
  61. + (NSString *)returnPathfromServerUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account;
  62. + (NSString *)returnFileNamePathFromFileName:(NSString *)metadataFileName serverUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase userId:(NSString *)userId account:(NSString *)account;
  63. + (NSString *)getDirectoryScan;
  64. + (NSString *)getMimeType:(NSString *)fileNameView;
  65. // ===== Share Permissions =====
  66. + (NSInteger)getPermissionsValueByCanEdit:(BOOL)canEdit andCanCreate:(BOOL)canCreate andCanChange:(BOOL)canChange andCanDelete:(BOOL)canDelete andCanShare:(BOOL)canShare andIsFolder:(BOOL) isFolder;
  67. + (BOOL)isPermissionToCanCreate:(NSInteger) permissionValue;
  68. + (BOOL)isPermissionToCanChange:(NSInteger) permissionValue;
  69. + (BOOL)isPermissionToCanDelete:(NSInteger) permissionValue;
  70. + (BOOL)isPermissionToCanShare:(NSInteger) permissionValue;
  71. + (BOOL)isAnyPermissionToEdit:(NSInteger) permissionValue;
  72. + (BOOL)isPermissionToRead:(NSInteger) permissionValue;
  73. + (BOOL)isPermissionToReadCreateUpdate:(NSInteger) permissionValue;
  74. // ===== Third parts =====
  75. + (NSString *)getExtension:(NSString*)fileName;
  76. + (NSDate *)datetimeWithOutTime:(NSDate *)datDate;
  77. + (NSString *)valueForKey:(NSString *)key fromQueryItems:(NSArray *)queryItems;
  78. + (NSDate *)getATime:(const char *)path;
  79. @end