mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
28 lines
636 B
C++
28 lines
636 B
C++
|
|
#include "IdentityStore.h"
|
||
|
|
|
||
|
|
bool IdentityStore::load(const char *name, mesh::LocalIdentity& id) {
|
||
|
|
bool loaded = false;
|
||
|
|
char filename[40];
|
||
|
|
sprintf(filename, "%s/%s.id", _dir, name);
|
||
|
|
if (_fs->exists(filename)) {
|
||
|
|
File file = _fs->open(filename);
|
||
|
|
if (file) {
|
||
|
|
loaded = id.readFrom(file);
|
||
|
|
file.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return loaded;
|
||
|
|
}
|
||
|
|
|
||
|
|
bool IdentityStore::save(const char *name, const mesh::LocalIdentity& id) {
|
||
|
|
char filename[40];
|
||
|
|
sprintf(filename, "%s/%s.id", _dir, name);
|
||
|
|
File file = _fs->open(filename, "w", true);
|
||
|
|
if (file) {
|
||
|
|
id.writeTo(file);
|
||
|
|
file.close();
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|