binlog add some functions
git-svn-id: svn://db.shs.com.ru/pip@60 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -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) {
|
int PIBinaryLog::writeBinLog(int id, const void *data, int size) {
|
||||||
if (size <= 0 || !canWrite()) return -1;
|
if (size <= 0 || !canWrite()) return -1;
|
||||||
switch (split_mode) {
|
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) {
|
PIByteArray PIBinaryLog::readBinLog(int id) {
|
||||||
if (!canRead()) return PIByteArray();
|
if (!canRead()) return PIByteArray();
|
||||||
BinLogRecord br = readRecord();
|
BinLogRecord br = readRecord();
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ public:
|
|||||||
//! Returns if rapid start enabled
|
//! Returns if rapid start enabled
|
||||||
bool rapidStart() const {return rapid_start;}
|
bool rapidStart() const {return rapid_start;}
|
||||||
|
|
||||||
|
//! Create binlog file with Filename = path
|
||||||
|
void createNewFile(const PIString &path);
|
||||||
|
|
||||||
//! Set \a PlayMode
|
//! Set \a PlayMode
|
||||||
void setPlayMode(PlayMode mode) {setProperty("playMode", (int)mode);}
|
void setPlayMode(PlayMode mode) {setProperty("playMode", (int)mode);}
|
||||||
@@ -169,6 +171,10 @@ public:
|
|||||||
//! Write one record to BinLog file, with ID = id, id must be greather than 0
|
//! Write one record to BinLog file, with ID = id, id must be greather than 0
|
||||||
int writeBinLog(int id, const void * data, int size);
|
int writeBinLog(int id, const void * data, int size);
|
||||||
|
|
||||||
|
//! Write one RAW record to BinLog file, with ID = id, Timestamp = time
|
||||||
|
int writeBinLog_raw(int id, const PISystemTime &time, const PIByteArray &data) {return writeBinLog_raw(id, time, data.data(), data.size_s());}
|
||||||
|
int writeBinLog_raw(int id, const PISystemTime &time, const void * data, int size);
|
||||||
|
|
||||||
//! Returns count of writed records
|
//! Returns count of writed records
|
||||||
int writeCount() const {return write_count;}
|
int writeCount() const {return write_count;}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user