binlog add some functions

git-svn-id: svn://db.shs.com.ru/pip@60 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2015-04-02 17:56:28 +00:00
parent 374a1f75dc
commit 617bddfe2a
2 changed files with 24 additions and 0 deletions

View File

@@ -187,6 +187,12 @@ PIString PIBinaryLog::createNewFile() {
}
void PIBinaryLog::createNewFile(const PIString &path) {
if (open(path, PIIODevice::WriteOnly)) newFile(file.path());
else piCoutObj << "Can't create new file, maybe path is invalid.";
}
int PIBinaryLog::writeBinLog(int id, const void *data, int size) {
if (size <= 0 || !canWrite()) return -1;
switch (split_mode) {
@@ -211,6 +217,18 @@ int PIBinaryLog::writeBinLog(int id, const void *data, int size) {
}
int PIBinaryLog::writeBinLog_raw(int id, const PISystemTime &time, const void *data, int size) {
if (size <= 0 || !canWrite()) return -1;
PIByteArray logdata;
logdata << id << size << time << PIByteArray::RawData(data, size);
int res = file.write(logdata.data(), logdata.size());
file.flush();
write_count++;
if (res > 0) return size;
else return res;
}
PIByteArray PIBinaryLog::readBinLog(int id) {
if (!canRead()) return PIByteArray();
BinLogRecord br = readRecord();