FIRCLSFileManager.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2019 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. @class FIRCLSInternalReport;
  16. @interface FIRCLSFileManager : NSObject
  17. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  18. @property(nonatomic, readonly) NSFileManager *underlyingFileManager;
  19. /**
  20. * Returns the folder containing the settings file
  21. */
  22. @property(nonatomic, readonly) NSString *settingsDirectoryPath;
  23. /**
  24. * Returns the path to the settings file
  25. */
  26. @property(nonatomic, readonly) NSString *settingsFilePath;
  27. /**
  28. * Path to the file that holds the ttl and keys that invalidate settings
  29. */
  30. @property(nonatomic, readonly) NSString *settingsCacheKeyPath;
  31. @property(nonatomic, readonly) NSString *rootPath;
  32. @property(nonatomic, readonly) NSString *cachesPath;
  33. @property(nonatomic, readonly) NSString *structurePath;
  34. @property(nonatomic, readonly) NSString *activePath;
  35. @property(nonatomic, readonly) NSString *processingPath;
  36. @property(nonatomic, readonly) NSString *pendingPath;
  37. @property(nonatomic, readonly) NSString *preparedPath;
  38. @property(nonatomic, readonly) NSArray *activePathContents;
  39. @property(nonatomic, readonly) NSArray *preparedPathContents;
  40. @property(nonatomic, readonly) NSArray *processingPathContents;
  41. - (BOOL)fileExistsAtPath:(NSString *)path;
  42. - (BOOL)createFileAtPath:(NSString *)path
  43. contents:(NSData *)data
  44. attributes:(NSDictionary<NSFileAttributeKey, id> *)attr;
  45. - (BOOL)createDirectoryAtPath:(NSString *)path;
  46. - (BOOL)removeItemAtPath:(NSString *)path;
  47. - (BOOL)removeContentsOfDirectoryAtPath:(NSString *)path;
  48. - (BOOL)moveItemAtPath:(NSString *)path toDirectory:(NSString *)destDir;
  49. - (BOOL)didCrashOnPreviousExecution;
  50. - (BOOL)metricKitDiagnosticFileExists;
  51. - (void)createEmptyMetricKitFile:(NSString *)reportPath;
  52. - (void)enumerateFilesInDirectory:(NSString *)directory
  53. usingBlock:(void (^)(NSString *filePath, NSString *extension))block;
  54. - (NSNumber *)fileSizeAtPath:(NSString *)path;
  55. - (NSArray *)contentsOfDirectory:(NSString *)path;
  56. // logic of managing files/directories
  57. - (BOOL)createReportDirectories;
  58. - (NSString *)setupNewPathForExecutionIdentifier:(NSString *)identifier;
  59. - (BOOL)moveItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error;
  60. - (NSData *)dataWithContentsOfFile:(NSString *)path;
  61. @end