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();
|
||||
String json();
|
||||
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() {
|
||||
SPIMaster::select_sd();
|
||||
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;
|
||||
for(std::map<String, String>::iterator it = _map.begin(); it != _map.end(); it++) {
|
||||
s += it->first;
|
||||
@ -150,10 +160,5 @@ void PlaylistManager::_save_mapping() {
|
||||
s += it->second;
|
||||
s += '\n';
|
||||
}
|
||||
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;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user