From e3fe75505f606622b3a21cf1c4b71b7144639e06 Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Thu, 9 Dec 2010 19:00:57 +0200 Subject: [PATCH] W1Store api cleanup for dir and file functions. Signed-off-by: Mika Laitio --- src/W1DataList.cc | 4 ++-- src/W1Store.cc | 14 +++++++------- src/W1Store.hh | 8 ++++---- src_test/test_w1_datalog_read.cc | 2 +- src_test/test_w1_datalog_write.cc | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/W1DataList.cc b/src/W1DataList.cc index 3e7743b..e05f9ba 100644 --- a/src/W1DataList.cc +++ b/src/W1DataList.cc @@ -23,7 +23,7 @@ W1DataList::W1DataList(string device_id_param) { string base_dir; device_id = device_id_param; - base_dir = W1Store::get_store_base_dir(); + base_dir = W1Store::get_base_dir_name(); device_dir = W1Util::concat_paths(base_dir, device_id); device_ch_dir = W1Util::concat_paths(base_dir, "cache"); device_ch_dir = W1Util::concat_paths(device_ch_dir, device_id); @@ -170,7 +170,7 @@ long int get_interval_type(Date *start_date, string W1DataList::get_day_data(Date *date) { string ret_val; - ret_val = W1Store::get_store_file_name(device_id, date); + ret_val = W1Store::get_file_name(device_id, date); return ret_val; } diff --git a/src/W1Store.cc b/src/W1Store.cc index 5db7b9b..360724e 100644 --- a/src/W1Store.cc +++ b/src/W1Store.cc @@ -32,7 +32,7 @@ W1Store::W1Store(string device_id, Date *date_time) { store_data = NULL; range_data = NULL; - store_file_name = get_store_file_name(device_id, date_time); + store_file_name = get_file_name(device_id, date_time); log_debug("data file name: %s\n", store_file_name.c_str()); } @@ -49,7 +49,7 @@ W1Store::~W1Store() { } } -void W1Store::set_store_base_dir(string store_param) { +void W1Store::set_base_dir_name(string store_param) { int pos; int b_count; @@ -63,11 +63,11 @@ void W1Store::set_store_base_dir(string store_param) { } } -string W1Store::get_store_base_dir() { +string W1Store::get_base_dir_name() { return store_base_dir; } -string W1Store::get_store_dir_name(string device_id, Date *date_time) { +string W1Store::get_dir_name(string device_id, Date *date_time) { string ret_val; char buffer[30]; @@ -77,7 +77,7 @@ string W1Store::get_store_dir_name(string device_id, Date *date_time) { return ret_val; } -string W1Store::get_store_file_name(string device_id, Date *date_time) { +string W1Store::get_file_name(string device_id, Date *date_time) { string ret_val; string fname; char buffer[30]; @@ -85,7 +85,7 @@ string W1Store::get_store_file_name(string device_id, Date *date_time) { snprintf(buffer, 30, "%d-%02d-%02d", date_time->year, date_time->month, date_time->day); fname = buffer; fname = fname + DATAFILE_SUFFIX; - ret_val = get_store_dir_name(device_id, date_time); + ret_val = get_dir_name(device_id, date_time); ret_val = W1Util::concat_paths(ret_val, fname); return ret_val; } @@ -98,7 +98,7 @@ void W1Store::store(std::string device_id, Date *date; date = new Date(); - f_path = get_store_file_name(device_id, date); + f_path = get_file_name(device_id, date); ostream = W1Util::open_for_writing(f_path.c_str()); // TODO: add mutex to protect string_list while it's read and emptied if (ostream != NULL) { diff --git a/src/W1Store.hh b/src/W1Store.hh index b05d9fe..2d4bb46 100644 --- a/src/W1Store.hh +++ b/src/W1Store.hh @@ -21,10 +21,10 @@ namespace w1 { plp::Date *date_time); W1Store(std::string file_name_param); virtual ~W1Store(); - static std::string get_store_base_dir(); - static void set_store_base_dir(std::string store_param); - static std::string get_store_dir_name(std::string device_id, plp::Date *ltime); - static std::string get_store_file_name(std::string device_id, plp::Date *ltime); + static std::string get_base_dir_name(); + static void set_base_dir_name(std::string store_param); + static std::string get_dir_name(std::string device_id, plp::Date *ltime); + static std::string get_file_name(std::string device_id, plp::Date *ltime); static void store(std::string device_id, std::list *string_list); void load(); Data *get_delta(); diff --git a/src_test/test_w1_datalog_read.cc b/src_test/test_w1_datalog_read.cc index acddf0d..50003ed 100644 --- a/src_test/test_w1_datalog_read.cc +++ b/src_test/test_w1_datalog_read.cc @@ -65,7 +65,7 @@ int main(int argc, char** argv) { else { log_warning("No storage location parameter given, using default location: %s\n", loc.c_str()); } - W1Store::set_store_base_dir(loc.c_str()); + W1Store::set_base_dir_name(loc); dlist = new W1DataList("0008014e9e09"); if (dlist != NULL) { dr = dlist->get_data_range(); diff --git a/src_test/test_w1_datalog_write.cc b/src_test/test_w1_datalog_write.cc index 807b862..5931f5f 100644 --- a/src_test/test_w1_datalog_write.cc +++ b/src_test/test_w1_datalog_write.cc @@ -70,7 +70,7 @@ int main(int argc, char** argv) { try_parse_long(argv[3], &store_interval); } log_info("start scanning, data saved to location: %s, scan interval: %d, store interval: %d\n", location.c_str(), scan_interval, store_interval); - W1Store::set_store_base_dir(location.c_str()); + W1Store::set_base_dir_name(location); scanner = new W1Scanner(); device_list = scanner->get_device_list(); round = 0; -- 2.41.1