PlaylistManager: Extracted create_mapping_txt from _save_mapping.
This commit is contained in:
parent
68ecc05712
commit
4f9174d362
@ -19,4 +19,5 @@ public:
|
|||||||
void scan_files();
|
void scan_files();
|
||||||
String json();
|
String json();
|
||||||
bool add_mapping(String id, String folder);
|
bool add_mapping(String id, String folder);
|
||||||
|
String create_mapping_txt();
|
||||||
};
|
};
|
||||||
|
@ -143,13 +143,7 @@ bool PlaylistManager::add_mapping(String id, String folder) {
|
|||||||
void PlaylistManager::_save_mapping() {
|
void PlaylistManager::_save_mapping() {
|
||||||
SPIMaster::select_sd();
|
SPIMaster::select_sd();
|
||||||
File f = SD.open("/_mapping.txt", "w");
|
File f = SD.open("/_mapping.txt", "w");
|
||||||
String s;
|
String s = create_mapping_txt();
|
||||||
for(std::map<String, String>::iterator it = _map.begin(); it != _map.end(); it++) {
|
|
||||||
s += it->first;
|
|
||||||
s += "=";
|
|
||||||
s += it->second;
|
|
||||||
s += '\n';
|
|
||||||
}
|
|
||||||
unsigned char* buf = new unsigned char[s.length()];
|
unsigned char* buf = new unsigned char[s.length()];
|
||||||
s.getBytes(buf, s.length());
|
s.getBytes(buf, s.length());
|
||||||
f.write(buf, s.length()-1);
|
f.write(buf, s.length()-1);
|
||||||
@ -157,3 +151,14 @@ void PlaylistManager::_save_mapping() {
|
|||||||
SPIMaster::select_sd(false);
|
SPIMaster::select_sd(false);
|
||||||
delete buf;
|
delete buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String PlaylistManager::create_mapping_txt() {
|
||||||
|
String s;
|
||||||
|
for(std::map<String, String>::iterator it = _map.begin(); it != _map.end(); it++) {
|
||||||
|
s += it->first;
|
||||||
|
s += "=";
|
||||||
|
s += it->second;
|
||||||
|
s += '\n';
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user