---------------------------------------------------------------------------
| 55 | } |
| 56 | //--------------------------------------------------------------------------- |
| 57 | bool 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 | //--------------------------------------------------------------------------- |
| 93 | String TStorageFile::GetFileNameToRotate(int num) |
| 94 | { |
nothing calls this directly
no test coverage detected