Index: src/ch/StringHelpers.cpp =================================================================== diff -u -ra27d1acf1bda3c25b6dcce0d0eb0278009ce63ae -r8dc649003961dad64b92da67426814fb5dd862e0 --- src/ch/StringHelpers.cpp (.../StringHelpers.cpp) (revision a27d1acf1bda3c25b6dcce0d0eb0278009ce63ae) +++ src/ch/StringHelpers.cpp (.../StringHelpers.cpp) (revision 8dc649003961dad64b92da67426814fb5dd862e0) @@ -1,21 +1,21 @@ -/*************************************************************************** -* Copyright (C) 2001-2008 by J�zef Starosczyk * -* ixen@copyhandler.com * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU Library General Public License * -* (version 2) as published by the Free Software Foundation; * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ +// ============================================================================ +// Copyright (C) 2001-2015 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ #include "stdafx.h" #include "ch.h" #include "StringHelpers.h" @@ -25,36 +25,38 @@ #define new DEBUG_NEW #endif -LPCTSTR GetSizeString(double dData, LPTSTR pszBuffer, size_t stMaxBufferSize) +CString GetSizeString(double dData) { if (dData < 0.0) - dData=0.0; + dData = 0.0; + CString strResult; if (dData < 1200.0) - _sntprintf(pszBuffer, stMaxBufferSize, _T("%.2f %s"), dData, GetResManager().LoadString(IDS_BYTE_STRING)); + strResult.Format(_T("%.2f %s"), dData, GetResManager().LoadString(IDS_BYTE_STRING)); else if (dData < 1228800.0) - _sntprintf(pszBuffer, stMaxBufferSize, _T("%.2f %s"), static_cast(dData)/1024.0, GetResManager().LoadString(IDS_KBYTE_STRING)); + strResult.Format(_T("%.2f %s"), static_cast(dData) / 1024.0, GetResManager().LoadString(IDS_KBYTE_STRING)); else if (dData < 1258291200.0) - _sntprintf(pszBuffer, stMaxBufferSize, _T("%.2f %s"), static_cast(dData)/1048576.0, GetResManager().LoadString(IDS_MBYTE_STRING)); + strResult.Format(_T("%.2f %s"), static_cast(dData) / 1048576.0, GetResManager().LoadString(IDS_MBYTE_STRING)); else - _sntprintf(pszBuffer, stMaxBufferSize, _T("%.2f %s"), static_cast(dData)/1073741824.0, GetResManager().LoadString(IDS_GBYTE_STRING)); + strResult.Format(_T("%.2f %s"), static_cast(dData) / 1073741824.0, GetResManager().LoadString(IDS_GBYTE_STRING)); - return pszBuffer; + return strResult; } -LPCTSTR GetSizeString(unsigned long long ullData, LPTSTR pszBuffer, size_t stMaxBufferSize, bool bStrict) +CString GetSizeString(unsigned long long ullData, bool bStrict) { if (ullData < 0) - ullData=0; + ullData = 0; + CString strResult; if (ullData >= 1258291200 && (!bStrict || (ullData % 1073741824) == 0)) - _sntprintf(pszBuffer, stMaxBufferSize, _T("%.2f %s"), (double)(ullData/1073741824.0), GetResManager().LoadString(IDS_GBYTE_STRING)); + strResult.Format(_T("%.2f %s"), (double)(ullData / 1073741824.0), GetResManager().LoadString(IDS_GBYTE_STRING)); else if (ullData >= 1228800 && (!bStrict || (ullData % 1048576) == 0)) - _sntprintf(pszBuffer, stMaxBufferSize, _T("%.2f %s"), (double)(ullData/1048576.0), GetResManager().LoadString(IDS_MBYTE_STRING)); + strResult.Format(_T("%.2f %s"), (double)(ullData / 1048576.0), GetResManager().LoadString(IDS_MBYTE_STRING)); else if (ullData >= 1200 && (!bStrict || (ullData % 1024) == 0)) - _sntprintf(pszBuffer, stMaxBufferSize, _T("%.2f %s"), (double)(ullData/1024.0), GetResManager().LoadString(IDS_KBYTE_STRING)); + strResult.Format(_T("%.2f %s"), (double)(ullData / 1024.0), GetResManager().LoadString(IDS_KBYTE_STRING)); else - _sntprintf(pszBuffer, stMaxBufferSize, _T("%I64u %s"), ullData, GetResManager().LoadString(IDS_BYTE_STRING)); + strResult.Format(_T("%I64u %s"), ullData, GetResManager().LoadString(IDS_BYTE_STRING)); - return pszBuffer; + return strResult; }