git-svn-id: svn://db.shs.com.ru/libs@105 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2016-07-24 14:03:59 +00:00
parent 1f71f140eb
commit 9fc412f646
9 changed files with 145 additions and 50 deletions

View File

@@ -1,11 +1,15 @@
#include "cdutils_k.h"
#include "cdutils_core.h"
#include "piconfig.h"
#include "pifile.h"
using namespace CDUtils;
KInterface::KInterface() {
core = Core::instance();
k_file = PIStringAscii("k.dat");
k_file_size = 0;
CONNECTU(core, K_Sended, this, sended);
CONNECTU(core, K_Received, this, received);
}
@@ -41,6 +45,11 @@ const KSection & KInterface::root() const {
}
int KInterface::count(bool recursive) const {
return core->k_.count(recursive);
}
void KInterface::send() {
core->K_Send();
}
@@ -50,6 +59,15 @@ void KInterface::request() {
}
bool KInterface::configure(const PIString & config, const PIString & sect) {
PIConfig conf(config, PIIODevice::ReadOnly);
PIConfig::Entry & e(conf.getValue(sect));
bool ret = false;
k_file = e.getValue("file", "k.dat", &ret);
return ret;
}
void KInterface::write(PIIODevice * d) {
core->k_write(d);
}
@@ -68,3 +86,20 @@ void KInterface::parse(PIIODevice * d) {
void KInterface::update(PIIODevice * d) {
core->k_update(d);
}
void KInterface::readFile() {
if (k_file.isEmpty()) return;
PIFile f(k_file, PIIODevice::ReadOnly);
read(&f);
k_file_size = f.size();
}
void KInterface::writeFile() {
if (k_file.isEmpty()) return;
PIFile f(k_file, PIIODevice::ReadWrite);
f.clear();
write(&f);
k_file_size = f.size();
}