MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / Save

Method Save

source/fdb.cpp:57–91  ·  view source on GitHub ↗

---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

55}
56//---------------------------------------------------------------------------
57bool TStorageFile::Save(AnsiString s)
58{
59 // check LogRotate...
60 if( rotation_type == 1 ) // by size
61 {
62 int mult;
63 switch( rotation_mult )
64 {
65 // 0,1,2 (KBs,MBs,GBs) [MBs]
66 case 0: mult = 1024; break;
67 case 1: mult = 1024*1024; break;
68 case 2: mult = 1024*1024*1024; break;
69 default: mult = 1024*1024; break;
70 }
71 if( file_size + s.Length() > rotation_size * mult )
72 {
73 RotateFile();
74 }
75 }
76
77 if( ! out.IsOpen() )
78 {
79 out.Open(GetFileName(), GENERIC_WRITE,
80 FILE_SHARE_READ | FILE_SHARE_WRITE,
81 OPEN_ALWAYS,
82 FILE_ATTRIBUTE_NORMAL);
83 if( ! out )
84 return false;
85 out.ToEnd();
86 file_size = out.GetSize64();
87 }
88 out << s;
89 file_size += out.Bytes;
90 return ! out.GetError();
91}
92//---------------------------------------------------------------------------
93String TStorageFile::GetFileNameToRotate(int num)
94{

Callers

nothing calls this directly

Calls 9

ToEndMethod · 0.80
GetSize64Method · 0.80
wsMethod · 0.80
wiMethod · 0.80
InsertEndChildMethod · 0.80
NewElementMethod · 0.80
IsOpenMethod · 0.45
OpenMethod · 0.45
GetErrorMethod · 0.45

Tested by

no test coverage detected