MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / ShrinkDebugFile

Function ShrinkDebugFile

src/commons/util/util.cpp:822–840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

820}
821
822void ShrinkDebugFile() {
823 // Scroll debug.log if it's getting too big
824 boost::filesystem::path pathLog = GetDataDir() / "debug.log";
825 FILE* file = fopen(pathLog.string().c_str(), "r");
826 if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000) {
827 // Restart the file with some of the end
828 char pch[200000];
829 fseek(file, -sizeof(pch), SEEK_END);
830 int nBytes = fread(pch, 1, sizeof(pch), file);
831 fclose(file);
832
833 file = fopen(pathLog.string().c_str(), "w");
834 if (file) {
835 fwrite(pch, 1, nBytes, file);
836 fclose(file);
837 }
838 } else if (file != NULL)
839 fclose(file);
840}
841
842//
843// "Never go to sea with two chronometers; take one or three."

Callers 1

LogPrintStrMethod · 0.85

Calls 1

fopenFunction · 0.85

Tested by

no test coverage detected