git-svn-id: svn://db.shs.com.ru/pip@551 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -87,8 +87,10 @@ bool PIBinaryLog::openDevice() {
|
|||||||
if (ld.isExists()) {
|
if (ld.isExists()) {
|
||||||
PIVector<PIFile::FileInfo> es = ld.allEntries();
|
PIVector<PIFile::FileInfo> es = ld.allEntries();
|
||||||
piForeachC(PIFile::FileInfo &i, es) {
|
piForeachC(PIFile::FileInfo &i, es) {
|
||||||
if (i.extension() == "binlog" && i.isFile())
|
if (i.extension() == "binlog" && i.isFile() && i.baseName().startsWith(filePrefix())) {
|
||||||
setPath(i.path);
|
setPath(i.path);
|
||||||
|
piBreak;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +122,7 @@ bool PIBinaryLog::openDevice() {
|
|||||||
fileEnd();
|
fileEnd();
|
||||||
}
|
}
|
||||||
play_time = 0;
|
play_time = 0;
|
||||||
if (!rapidStart()) is_started = true;
|
if (!rapid_start) is_started = true;
|
||||||
}
|
}
|
||||||
startlogtime = PISystemTime::current();
|
startlogtime = PISystemTime::current();
|
||||||
pause_time = PISystemTime();
|
pause_time = PISystemTime();
|
||||||
@@ -531,6 +533,30 @@ PIBinaryLog::BinLogInfo PIBinaryLog::getLogInfo(const PIString & path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PIBinaryLog::cutBinLog(const PIBinaryLog::BinLogInfo & src, const PIString & dst, int from, int to) {
|
||||||
|
PIBinaryLog slog;
|
||||||
|
if (!slog.open(src.path, PIIODevice::ReadOnly)) return false;
|
||||||
|
PIVector<int> ids = src.records.keys();
|
||||||
|
slog.seekTo(from);
|
||||||
|
PIBinaryLog dlog;
|
||||||
|
dlog.createNewFile(dst);
|
||||||
|
bool first = true;
|
||||||
|
BinLogRecord br;
|
||||||
|
PISystemTime st;
|
||||||
|
while (!slog.isEnd() && ((slog.pos() <= to) || to < 0)) {
|
||||||
|
br = slog.readRecord();
|
||||||
|
if (first) {
|
||||||
|
st = br.timestamp;
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
if (ids.contains(br.id)) {
|
||||||
|
dlog.writeBinLog_raw(br.id, br.timestamp - st, br.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString PIBinaryLog::constructFullPathDevice() const {
|
PIString PIBinaryLog::constructFullPathDevice() const {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
ret << logDir() << ":" << filePrefix() << ":" << defaultID() << ":";
|
ret << logDir() << ":" << filePrefix() << ":" << defaultID() << ":";
|
||||||
|
|||||||
@@ -266,6 +266,7 @@ public:
|
|||||||
|
|
||||||
//! Get binlog info and statistic
|
//! Get binlog info and statistic
|
||||||
static BinLogInfo getLogInfo(const PIString & path);
|
static BinLogInfo getLogInfo(const PIString & path);
|
||||||
|
static bool cutBinLog(const BinLogInfo & src, const PIString & dst, int from, int to);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PIString fullPathPrefix() const {return PIStringAscii("binlog");}
|
PIString fullPathPrefix() const {return PIStringAscii("binlog");}
|
||||||
|
|||||||
Reference in New Issue
Block a user