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,6 +143,16 @@ 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 = create_mapping_txt();
|
||||||
|
unsigned char* buf = new unsigned char[s.length()];
|
||||||
|
s.getBytes(buf, s.length());
|
||||||
|
f.write(buf, s.length()-1);
|
||||||
|
f.close();
|
||||||
|
SPIMaster::select_sd(false);
|
||||||
|
delete buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
String PlaylistManager::create_mapping_txt() {
|
||||||
String s;
|
String s;
|
||||||
for(std::map<String, String>::iterator it = _map.begin(); it != _map.end(); it++) {
|
for(std::map<String, String>::iterator it = _map.begin(); it != _map.end(); it++) {
|
||||||
s += it->first;
|
s += it->first;
|
||||||
@ -150,10 +160,5 @@ void PlaylistManager::_save_mapping() {
|
|||||||
s += it->second;
|
s += it->second;
|
||||||
s += '\n';
|
s += '\n';
|
||||||
}
|
}
|
||||||
unsigned char* buf = new unsigned char[s.length()];
|
return s;
|
||||||
s.getBytes(buf, s.length());
|
}
|
||||||
f.write(buf, s.length()-1);
|
|
||||||
f.close();
|
|
||||||
SPIMaster::select_sd(false);
|
|
||||||
delete buf;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user