PersistentStorage.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. namespace I2.Loc
  3. {
  4. public static class PersistentStorage
  5. {
  6. public static void SetSetting_String(string key, string value)
  7. {
  8. if (PersistentStorage.mStorage == null)
  9. {
  10. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  11. }
  12. PersistentStorage.mStorage.SetSetting_String(key, value);
  13. }
  14. public static string GetSetting_String(string key, string defaultValue)
  15. {
  16. if (PersistentStorage.mStorage == null)
  17. {
  18. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  19. }
  20. return PersistentStorage.mStorage.GetSetting_String(key, defaultValue);
  21. }
  22. public static void DeleteSetting(string key)
  23. {
  24. if (PersistentStorage.mStorage == null)
  25. {
  26. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  27. }
  28. PersistentStorage.mStorage.DeleteSetting(key);
  29. }
  30. public static bool HasSetting(string key)
  31. {
  32. if (PersistentStorage.mStorage == null)
  33. {
  34. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  35. }
  36. return PersistentStorage.mStorage.HasSetting(key);
  37. }
  38. public static void ForceSaveSettings()
  39. {
  40. if (PersistentStorage.mStorage == null)
  41. {
  42. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  43. }
  44. PersistentStorage.mStorage.ForceSaveSettings();
  45. }
  46. public static bool CanAccessFiles()
  47. {
  48. if (PersistentStorage.mStorage == null)
  49. {
  50. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  51. }
  52. return PersistentStorage.mStorage.CanAccessFiles();
  53. }
  54. public static bool SaveFile(PersistentStorage.eFileType fileType, string fileName, string data, bool logExceptions = true)
  55. {
  56. if (PersistentStorage.mStorage == null)
  57. {
  58. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  59. }
  60. return PersistentStorage.mStorage.SaveFile(fileType, fileName, data, logExceptions);
  61. }
  62. public static string LoadFile(PersistentStorage.eFileType fileType, string fileName, bool logExceptions = true)
  63. {
  64. if (PersistentStorage.mStorage == null)
  65. {
  66. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  67. }
  68. return PersistentStorage.mStorage.LoadFile(fileType, fileName, logExceptions);
  69. }
  70. public static bool DeleteFile(PersistentStorage.eFileType fileType, string fileName, bool logExceptions = true)
  71. {
  72. if (PersistentStorage.mStorage == null)
  73. {
  74. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  75. }
  76. return PersistentStorage.mStorage.DeleteFile(fileType, fileName, logExceptions);
  77. }
  78. public static bool HasFile(PersistentStorage.eFileType fileType, string fileName, bool logExceptions = true)
  79. {
  80. if (PersistentStorage.mStorage == null)
  81. {
  82. PersistentStorage.mStorage = new I2CustomPersistentStorage();
  83. }
  84. return PersistentStorage.mStorage.HasFile(fileType, fileName, logExceptions);
  85. }
  86. private static I2CustomPersistentStorage mStorage;
  87. public enum eFileType
  88. {
  89. Raw,
  90. Persistent,
  91. Temporal,
  92. Streaming
  93. }
  94. }
  95. }