mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-04 07:36:03 +00:00
Initial commit
This commit is contained in:
27
src/helpers/IdentityStore.cpp
Normal file
27
src/helpers/IdentityStore.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user