X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FDeviceConfig.cc;h=f9e8f72684747cee8057c848ca8a42b6f3ec7867;hb=8c97cbb9b5f8997fe9ab3917fcbea66d74b45837;hp=ee06135a4270cc4594c0a2d6770a5ae18775c87b;hpb=6c332c9dfe49d7fe08478946decce32a8f577ef4;p=lib1wire.git diff --git a/src/DeviceConfig.cc b/src/DeviceConfig.cc index ee06135..f9e8f72 100644 --- a/src/DeviceConfig.cc +++ b/src/DeviceConfig.cc @@ -115,7 +115,6 @@ void DeviceConfig::set_cfg_value(string key, string value) { cfg_dir = get_dir_name(device_id); cfg_fl = DEVICE_CONFIG__FILE_NAME; - set_config_value(cfg_dir.c_str(), cfg_fl.c_str(), DEVICE_CONFIG__SECTION_TYPE, @@ -147,12 +146,15 @@ ConfigHandle *DeviceConfig::load_device_config(string device_id_param) { ret_val = NULL; cfg_dir = get_dir_name(device_id_param); if (cfg_dir.empty() == false) { + if (access(cfg_dir.c_str(), W_OK) != 0) { + W1Util::mkdirs(cfg_dir.c_str()); + } cfg_fl = get_file_name(device_id_param); ctx = uci_alloc_context(); if (ctx != NULL) { log_debug("uci_set_confdir: %s\n", cfg_dir.c_str()); uci_set_confdir(ctx, cfg_dir.c_str()); - if (access(cfg_fl.c_str(), R_OK) != 0) { + if (access(cfg_fl.c_str(), R_OK) == 0) { log_debug("loading file: %s\n", cfg_fl.c_str()); err_flg = uci_load(ctx, cfg_fl.c_str(), &pkg); if (err_flg == UCI_OK) { @@ -164,9 +166,12 @@ ConfigHandle *DeviceConfig::load_device_config(string device_id_param) { set_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE, "unknowntype"); } } + else { + log_error("Failed to load device device configuration, file does not exit: %s.\n", cfg_fl.c_str()); + } } else { - log_error("Failed to load device device configurations, invalid device id: %s.\n", cfg_dir.c_str()); + log_error("Failed to load device device configuration, invalid device id: %s.\n", cfg_dir.c_str()); } } return ret_val;