File tree 3 files changed +10
-10
lines changed
3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,4 @@ using CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE = const char *;
66
66
67
67
// ==================== Security Configuration Overrides ====================
68
68
69
- #ifndef CHIP_CONFIG_KVS_PATH
70
- #define CHIP_CONFIG_KVS_PATH "/tmp/chip_kvs"
71
- #endif // CHIP_CONFIG_KVS_PATH
69
+ #define CHIP_DEFAULT_CONFIG_KVS_FILE_NAME "chip_kvs"
Original file line number Diff line number Diff line change @@ -97,7 +97,8 @@ ChipLinuxStorage * PosixConfig::GetStorageForNamespace(Key key)
97
97
98
98
CHIP_ERROR PosixConfig::Init ()
99
99
{
100
- return PersistedStorage::KeyValueStoreMgrImpl ().Init (CHIP_CONFIG_KVS_PATH);
100
+ std::string filePath = GetFilePath (CHIP_DEFAULT_CONFIG_KVS_FILE_NAME);
101
+ return PersistedStorage::KeyValueStoreMgrImpl ().Init (filePath.c_str ());
101
102
}
102
103
103
104
CHIP_ERROR PosixConfig::ReadConfigValue (Key key, bool & val)
@@ -453,17 +454,17 @@ bool PosixConfig::ConfigValueExists(Key key)
453
454
return storage->HasValue (key.Name );
454
455
}
455
456
456
- std::string PosixConfig::GetFilePath (std::string defaultFileName)
457
+ std::string PosixConfig::GetFilePath (const std::string & defaultFileName)
457
458
{
458
459
// Match what GetFilename in ExamplePersistentStorage.cpp does.
459
- const char * dir = getenv (" TMPDIR" );
460
+ const char *dir = std:: getenv (" TMPDIR" );
460
461
if (dir == nullptr )
461
462
{
462
463
dir = " /tmp" ;
463
464
}
464
- std::string storageDir = dir;
465
-
466
- return storageDir + " / " + defaultFileName ;
465
+ std::filesystem::path storageDir ( dir) ;
466
+ std::filesystem::path filePath = storageDir / defaultFileName;
467
+ return filePath. string () ;
467
468
}
468
469
469
470
CHIP_ERROR PosixConfig::EnsureNamespace (const char * ns)
Original file line number Diff line number Diff line change 25
25
26
26
#include < functional>
27
27
#include < string>
28
+ #include < filesystem>
28
29
#include < inttypes.h>
29
30
30
31
#include < lib/core/CHIPError.h>
@@ -112,7 +113,7 @@ class PosixConfig
112
113
113
114
private:
114
115
static ChipLinuxStorage * GetStorageForNamespace (Key key);
115
- static std::string GetFilePath (std::string defaultFileName);
116
+ static std::string GetFilePath (const std::string & defaultFileName);
116
117
};
117
118
118
119
struct PosixConfig ::Key
You can’t perform that action at this time.
0 commit comments