No Description

FIRInstanceIDBackupExcludedPlist.h 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright 2019 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @interface FIRInstanceIDBackupExcludedPlist : NSObject
  18. /**
  19. * Caches the plist contents in memory so we don't hit the disk each time we want
  20. * to query something in the plist. This is loaded lazily i.e. if you write to the
  21. * plist the contents you want to write will be stored here if the write was
  22. * successful. The other case where it is loaded is if you read the plist contents
  23. * by calling `contentAsDictionary`.
  24. *
  25. * In case you write to the plist and then try to read the file using
  26. * `contentAsDictionary` we would just return the cachedPlistContents since it would
  27. * represent the disk contents.
  28. */
  29. @property(nonatomic, readonly, strong) NSDictionary *cachedPlistContents;
  30. /**
  31. * Init a backup excluded plist file.
  32. *
  33. * @param fileName The filename for the plist file.
  34. * @param subDirectory The subdirectory in Application Support to save the plist.
  35. *
  36. * @return Helper which allows to read write data to a backup excluded plist.
  37. */
  38. - (instancetype)initWithFileName:(NSString *)fileName subDirectory:(NSString *)subDirectory;
  39. /**
  40. * Write dictionary data to the backup excluded plist file. If the file does not exist
  41. * it would be created before writing to it.
  42. *
  43. * @param dict The data to be written to the plist.
  44. * @param error The error object if any while writing the data.
  45. *
  46. * @return YES if the write was successful else NO.
  47. */
  48. - (BOOL)writeDictionary:(NSDictionary *)dict error:(NSError **)error;
  49. /**
  50. * Delete the backup excluded plist created with the above filename.
  51. *
  52. * @param error The error object if any while deleting the file.
  53. *
  54. * @return YES If the delete was successful else NO.
  55. */
  56. - (BOOL)deleteFile:(NSError **)error;
  57. /**
  58. * The contents of the plist file. We also store the contents of the file in-memory.
  59. * If the in-memory contents are valid we return the in-memory contents else we read
  60. * the file from disk.
  61. *
  62. * @return A dictionary object that contains the contents of the plist file if the file
  63. * exists else nil.
  64. */
  65. - (NSDictionary *)contentAsDictionary;
  66. /**
  67. * Check if the plist exists on the disk or not.
  68. *
  69. * @return YES if the file exists on the disk else NO.
  70. */
  71. - (BOOL)doesFileExist;
  72. @end