3 #include "filesystem.h"
5 #include "preferences.inc"
10 ChannelDB::ChannelDB()
14 ChannelDB::~ChannelDB()
16 channels.remove_all_objects();
19 char* ChannelDB::prefix_to_path(char *path, char *prefix)
22 char directory[BCTEXTLEN];
23 sprintf(directory, BCASTDIR);
24 fs.complete_path(directory);
25 fs.join_names(path, directory, prefix);
29 void ChannelDB::load(char *prefix)
34 prefix_to_path(path, prefix);
35 channels.remove_all_objects();
37 int done = file.read_from_file(path, 1);
39 channels.remove_all_objects();
43 Channel *channel = new Channel;
44 if(!(done = channel->load(&file)))
45 channels.append(channel);
53 void ChannelDB::save(char *prefix)
58 prefix_to_path(path, prefix);
62 for(int i = 0; i < channels.total; i++)
65 channels.values[i]->save(&file);
67 file.terminate_string();
68 file.write_to_file(path);
72 Channel* ChannelDB::get(int number)
74 if(number >= 0 && number < channels.total)
75 return channels.values[number];
80 void ChannelDB::copy_from(ChannelDB *src)
83 for(int i = 0; i < src->size(); i++)
85 Channel *dst = new Channel;
87 dst->copy_settings(src->get(i));
93 return channels.total;
96 void ChannelDB::clear()
98 channels.remove_all_objects();
101 void ChannelDB::append(Channel *channel)
103 channels.append(channel);
106 void ChannelDB::remove_number(int number)
108 channels.remove_number(number);
111 void ChannelDB::set(int number, Channel *ptr)
113 channels.values[number] = ptr;