diff --git a/source/system_quotas.cc b/source/system_quotas.cc index f5f5dcb..c92f609 100644 --- a/source/system_quotas.cc +++ b/source/system_quotas.cc @@ -21,9 +21,7 @@ void Quotas_sys::set_map_gui(map_str_str &map_gui) { void Quotas_sys::check_partition_mount() { string key = ""; - // Todo: - // Заменить на чтение файла средствами с++ - string response = obj_process_call.call_all_sections("cat /proc/mounts"); + string response = Utils::file_read("/proc/mounts"); for (const auto& iter: (*map_device)) { key = iter.first; if (response.find(key) != string::npos) { @@ -172,21 +170,16 @@ bool Quotas_sys::on_quota_sw(string partition, int mode) { bool Quotas_sys::off_quota(string partition, string quota_hw, string quota_sw) { string cmd = ""; if (map_hw_or_sw.find(partition) != map_hw_or_sw.end()) { - if (map_hw_or_sw[partition] == "hw") { + if (this->wrapper_hw_sw(partition) == "hw") { cmd = quota_hw + " " + partition; + obj_process_system.call(cmd, ""); return true; } - else if (map_hw_or_sw[partition] == "sw") { + else if (this->wrapper_hw_sw(partition) == "sw") { cmd = quota_sw + " " + partition; + obj_process_system.call(cmd, ""); return true; } - else { - // TODO: - // Убрать после тестирования - throw "Опа цэ!"; - return false; - } - obj_process_system.call(cmd, ""); } return false; diff --git a/source/util.cc b/source/util.cc index 09ed1f5..cb05f5b 100644 --- a/source/util.cc +++ b/source/util.cc @@ -213,4 +213,18 @@ int synopsis_show(string str_link) { } return system(cmd.c_str()); } + +string file_read(string filename) { + string line; + string buffer; + std::ifstream in(filename); // окрываем файл для чтения + if (in.is_open()) + { + while (getline(in, line)) + { + buffer += line; + } + } + return buffer; +} } \ No newline at end of file diff --git a/source/util.h b/source/util.h index 2415ba8..d857b72 100644 --- a/source/util.h +++ b/source/util.h @@ -27,5 +27,6 @@ unsigned short read_uid_min_max(string filename, string search); vector pars_users(); string read_passwd(string username); int synopsis_show(string str_link); +string file_read(string filename); } #endif \ No newline at end of file