Clone
ixen <ixen@copyhandler.com>
committed
on 26 Dec 16
Improved handling of logger waiting failures (CH-322)
ch-1.40 + 2 more
src/libchengine/TSizeFormatter.cpp (+1 -1)
45 45         }
46 46
47 47         TSizeFormatter::TSizeFormatter(const wchar_t* strBytes, const wchar_t* strKBytes, const wchar_t* strMBytes, const wchar_t* strGBytes, const wchar_t* strTBytes) :
48 48                 m_strBytes(strBytes),
49 49                 m_strKBytes(strKBytes),
50 50                 m_strMBytes(strMBytes),
51 51                 m_strGBytes(strGBytes),
52 52                 m_strTBytes(strTBytes)
53 53         {
54 54         }
55 55
56 56         void TSizeFormatter::SetValues(const wchar_t* strBytes, const wchar_t* strKBytes, const wchar_t* strMBytes, const wchar_t* strGBytes, const wchar_t* strTBytes)
57 57         {
58 58                 m_strBytes = strBytes;
59 59                 m_strKBytes = strKBytes;
60 60                 m_strMBytes = strMBytes;
61 61                 m_strGBytes = strGBytes;
62 62                 m_strTBytes = strTBytes;
63 63         }
64 64
65           std::wstring TSizeFormatter::GetSizeString(unsigned long long ullData, bool bStrict) const
  65         string::TString TSizeFormatter::GetSizeString(unsigned long long ullData, bool bStrict) const
66 66         {
67 67                 const size_t stMaxSize = 512;
68 68                 wchar_t szData[ stMaxSize ] = { 0 };
69 69
70 70                 if(ullData >= 1288490188800 && (!bStrict || (ullData % 1099511627776) == 0))
71 71                         _sntprintf_s(szData, stMaxSize, L"%.2f %s", (double)(ullData / 1099511627776.0), m_strTBytes.c_str());
72 72                 else if(ullData >= 1258291200 && (!bStrict || (ullData % 1073741824) == 0))
73 73                         _sntprintf_s(szData, stMaxSize, L"%.2f %s", (double)(ullData / 1073741824.0), m_strGBytes.c_str());
74 74                 else if(ullData >= 1228800 && (!bStrict || (ullData % 1048576) == 0))
75 75                         _sntprintf_s(szData, stMaxSize, _T("%.2f %s"), (double)(ullData / 1048576.0), m_strMBytes.c_str());
76 76                 else if(ullData >= 1200 && (!bStrict || (ullData % 1024) == 0))
77 77                         _sntprintf_s(szData, stMaxSize, _T("%.2f %s"), (double)(ullData / 1024.0), m_strKBytes.c_str());
78 78                 else
79 79                         _sntprintf_s(szData, stMaxSize, _T("%I64u %s"), ullData, m_strBytes.c_str());
80 80
81 81                 return szData;
82 82         }
83 83
84 84         void TSizeFormatter::StoreInConfig(chengine::TConfig& rConfig, PCTSTR pszNodeName) const
85 85         {