int i=0;
for (i = 0; i < m_wLangIds.GetSize(); i++)
{
- CString Language = GetLanguageString(m_wLangIds[i]);
- if ( !Language.IsEmpty() )
+ String Language = GetLanguageString(m_wLangIds[i]);
+ if ( !Language.empty() )
{
- int idx = m_ctlLangList.AddString(Language);
+ int idx = m_ctlLangList.AddString(Language.c_str());
m_ctlLangList.SetItemData(idx, i);
}
}
return -1;
}
-CString CLanguageSelect::GetLanguageString( WORD LangId )
+String CLanguageSelect::GetLanguageString( WORD LangId )
{
int idx = GetLanguageArrayIndex(LangId);
if (idx == -1) return _T("");
// Localized name
- CString Language = LoadResString(lang_map[idx].m_IdName);
+ String Language = theApp.LoadString(lang_map[idx].m_IdName);
// Append native name
- Language += _T(" - ") + GetNativeLanguageNameString(idx);
+ Language += _T(" - ");
+ Language += GetNativeLanguageNameString(idx);
return Language;
}
UINT GetDocResId();
CString GetPath( LPCTSTR FileName) const;
CString GetLanguagePath(LPCTSTR FileName) const;
- CString GetLanguageString( WORD LangId );
+ String GetLanguageString( WORD LangId );
CString GetNativeLanguageNameString( int idx );
void LoadAndDisplayLanguages();
else
{
// Try to load the title from the resources.
- VERIFY(m_strTitle.LoadString(nTitleID));
+ m_strTitle = LoadResString(nTitleID);
}
// Save the information about the message box.
- VERIFY(m_strMessage.LoadString(nMessageID));
+ m_strMessage = LoadResString(nMessageID);
m_nStyle = nStyle;
m_nHelp = nHelp;
/*
* Method for setting the message to be displayed in the message box.
*/
-inline void CMessageBoxDialog::SetMessage ( CString strMessage )
+inline void CMessageBoxDialog::SetMessage ( LPCTSTR strMessage )
{
- ASSERT(!strMessage.IsEmpty());
+ ASSERT(*strMessage != '\0');
// Save the message text.
m_strMessage = strMessage;
*/
inline void CMessageBoxDialog::SetMessage ( UINT nMessageID )
{
- // Create a string for storing the message.
- CString strMessage = _T("");
-
// Load the message from the resources.
- VERIFY(strMessage.LoadString(nMessageID));
-
- ASSERT(!strMessage.IsEmpty());
-
- // Save the message text.
- m_strMessage = strMessage;
+ m_strMessage = LoadResString(nMessageID);
+ ASSERT(!m_strMessage.empty());
}
/*
* Method for retrieving the message to be displayed in the message box.
*/
-inline CString CMessageBoxDialog::GetMessage ( )
+inline const String &CMessageBoxDialog::GetMessage ( )
{
// Return the message text.
return m_strMessage;
/*
* Method for setting the title to be displayed in the message box.
*/
-inline void CMessageBoxDialog::SetTitle ( CString strTitle )
+inline void CMessageBoxDialog::SetTitle ( LPCTSTR strTitle )
{
// Check whether a title was given.
- if ( strTitle.IsEmpty() )
+ if ( *strTitle == '\0' )
{
// Use the application name as the title.
strTitle = AfxGetAppName();
*/
inline void CMessageBoxDialog::SetTitle ( UINT nTitleID )
{
- // Create a string for storing the title.
- CString strTitle = _T("");
-
// Check whether an ID was given.
if ( nTitleID == 0 )
{
// Use the application name as the title.
- strTitle = AfxGetAppName();
+ m_strTitle = AfxGetAppName();
}
else
{
// Try to load the string from the resources.
- VERIFY(strTitle.LoadString(nTitleID));
-
- ASSERT(!strTitle.IsEmpty());
+ m_strTitle = LoadResString(nTitleID);
+ ASSERT(!m_strTitle.empty());
}
-
- // Save the title.
- m_strTitle = strTitle;
}
/*
* Method for retrieving the title to be displayed in the message box.
*/
-inline CString CMessageBoxDialog::GetTitle ( )
+inline const String &CMessageBoxDialog::GetTitle ( )
{
// Return the title of the message box.
return m_strTitle;
}
// Set the title of the dialog.
- SetWindowText(m_strTitle);
+ SetWindowText(m_strTitle.c_str());
// Set the help ID of the dialog.
SetHelpID(m_nHelp);
// Check whether this button is the default button.
if ( m_aButtons.GetAt(i).nID == m_nDefaultButton )
{
- // Create two strings for the button text.
- CString strButtonText = _T("");
- CString strFullText = _T("");
-
// Try to load the text for the button.
- VERIFY(strButtonText.LoadString(m_aButtons.GetAt(i).nTitle));
-
- // Use the button text as the full text.
- strFullText = strButtonText;
-
+ String strButtonText = LoadResString(m_aButtons.GetAt(i).nTitle);
// Check whether the timeout is finished.
if ( m_nTimeoutSeconds > 0 )
{
// Add the remaining seconds to the text of the button.
- strFullText.Format(_T("%s = %d"), strButtonText,
- m_nTimeoutSeconds);
- }
-
- // Try to retrieve a handle for the button.
- CWnd* pButtonWnd = GetDlgItem(m_aButtons.GetAt(i).nID);
-
- ASSERT(pButtonWnd);
-
- // Check whether the handle was retrieved successfully.
- if ( pButtonWnd != NULL )
- {
- // Set the text of the button.
- pButtonWnd->SetWindowText(strFullText);
+ TCHAR szTimeoutSeconds[40];
+ wsprintf(szTimeoutSeconds, _T(" = %d"), m_nTimeoutSeconds);
+ strButtonText += szTimeoutSeconds;
}
+ // Set the text of the button.
+ SetDlgItemText(m_aButtons.GetAt(i).nID, strButtonText.c_str());
}
}
}
int nChecksum = 0;
// Run through the message string.
- for ( int i = 0; i < m_strMessage.GetLength(); i++ )
+ for ( int i = 0; i < m_strMessage.length(); i++ )
{
// Get the char at the given position and add it to the checksum.
- nChecksum += ((int)m_strMessage.GetAt(i)) * i;
+ nChecksum += (int)m_strMessage[i] * i;
}
// Convert the checksum to a string.
*/
void CMessageBoxDialog::CreateMessageControl ( )
{
- ASSERT(!m_strMessage.IsEmpty());
+ ASSERT(!m_strMessage.empty());
// Create a DC for accessing the display driver.
CDC dcDisplay;
CRect rcMessage(0, 0, nMaxWidth, nMaxWidth);
// Draw the text and retrieve the size of the text.
- dcDisplay.DrawText(m_strMessage, rcMessage, DT_LEFT | DT_NOPREFIX |
+ dcDisplay.DrawText(m_strMessage.c_str(), rcMessage, DT_LEFT | DT_NOPREFIX |
DT_WORDBREAK | DT_CALCRECT);
// Save the size required for the message.
}
// Create the static control for the message.
- m_stcMessage.Create(m_strMessage, dwStyle, rcDummy, this,
+ m_stcMessage.Create(m_strMessage.c_str(), dwStyle, rcDummy, this,
(UINT)IDC_STATIC);
// Check whether the text will be read from right to left.
( m_nStyle & MB_DONT_ASK_AGAIN ) )
{
// Create a variable for storing the title of the checkbox.
- CString strCheckboxTitle = _T("");
+ String strCheckboxTitle;
// Check which style is used.
if ( m_nStyle & MB_DONT_DISPLAY_AGAIN )
{
// Load the string for the checkbox.
- VERIFY(strCheckboxTitle.LoadString(
- IDS_MESSAGEBOX_DONT_DISPLAY_AGAIN));
+ strCheckboxTitle = LoadResString(IDS_MESSAGEBOX_DONT_DISPLAY_AGAIN);
}
else
{
if ( m_nStyle & MB_DONT_ASK_AGAIN )
{
// Load the string for the checkbox.
- VERIFY(strCheckboxTitle.LoadString(
- IDS_MESSAGEBOX_DONT_ASK_AGAIN));
+ strCheckboxTitle = LoadResString(IDS_MESSAGEBOX_DONT_ASK_AGAIN);
}
}
- ASSERT(!strCheckboxTitle.IsEmpty());
+ ASSERT(!strCheckboxTitle.empty());
// Create a handle to access the DC of the dialog.
CClientDC dc(this);
CFont* pOldFont = dc.SelectObject(pWndFont);
// Retrieve the size of the text.
- m_sCheckbox = dc.GetTextExtent(strCheckboxTitle);
+ m_sCheckbox = dc.GetTextExtent(strCheckboxTitle.c_str(), strCheckboxTitle.length());
// Add the additional value to the width of the checkbox.
m_sCheckbox.cx += XDialogUnitToPixel(CX_CHECKBOX_ADDON);
CButton btnCheckbox;
// Create the checkbox.
- btnCheckbox.Create(strCheckboxTitle, WS_CHILD | WS_VISIBLE |
+ btnCheckbox.Create(strCheckboxTitle.c_str(), WS_CHILD | WS_VISIBLE |
WS_TABSTOP | BS_AUTOCHECKBOX, rcDummy, this, IDCHECKBOX);
// Check whether the checkbox should be marked checked at startup.
for ( int i = 0; i < m_aButtons.GetSize(); i++ )
{
// Create a string and load the title of the button.
- CString strButtonTitle;
- VERIFY(strButtonTitle.LoadString(m_aButtons.GetAt(i).nTitle));
-
- // Create a string with the text used to determine the length.
- CString strLengthTest = strButtonTitle;
-
+ String strButtonText = LoadResString(m_aButtons.GetAt(i).nTitle);
// Check whether there's a timeout set.
if ( m_nTimeoutSeconds > 0 )
{
- // Create a string with the longest timeout text.
- CString strTimeoutText = _T("");
- strTimeoutText.Format(_T("%s = %d"), strLengthTest,
- m_nTimeoutSeconds);
-
- // Use this text to determine the length of the string.
- strLengthTest = strTimeoutText;
+ // Add the remaining seconds to the text of the button.
+ TCHAR szTimeoutSeconds[40];
+ wsprintf(szTimeoutSeconds, _T(" = %d"), m_nTimeoutSeconds);
+ strButtonText += szTimeoutSeconds;
}
// Retrieve the size of the text.
- CSize sButtonText = dc.GetTextExtent(strLengthTest);
+ CSize sButtonText = dc.GetTextExtent(strButtonText.c_str(), strButtonText.length());
// Resize the button.
m_sButton.cx = max(m_sButton.cx, sButtonText.cx);
CButton btnControl;
// Create the button.
- btnControl.Create(strButtonTitle, WS_CHILD | WS_VISIBLE | WS_TABSTOP,
+ btnControl.Create(strButtonText.c_str(), WS_CHILD | WS_VISIBLE | WS_TABSTOP,
rcDummy, this, m_aButtons.GetAt(i).nID);
// Set the font of the control.
UINT GetStyle ( );
// Methods for setting the message to be displayed in the message box.
- void SetMessage ( CString strMessage );
+ void SetMessage ( LPCTSTR strMessage );
void SetMessage ( UINT nMessageID );
// Method for retrieving the message to be displayed in the message box.
- CString GetMessage ( );
+ const String &GetMessage ( );
// Methods for setting the title to be displayed in the message box.
- void SetTitle ( CString strTitle );
+ void SetTitle ( LPCTSTR strTitle );
void SetTitle ( UINT nTitleID );
// Method for retrieving the title to be displayed in the message box.
- CString GetTitle ( );
+ const String &GetTitle ( );
// Methods for setting the icon to be displayed in the message box.
void SetMessageIcon ( HICON hIcon );
//////////////////////////////////////////////////////////////////////////
// Private member variables of this dialog.
- CString m_strMessage; // Message to be displayed.
- CString m_strTitle; // Title to be used.
+ String m_strMessage; // Message to be displayed.
+ String m_strTitle; // Title to be used.
UINT m_nStyle; // Style of the message box.
UINT m_nHelp; // Help context of the message box.
m_statusFetched = -1;
m_lastError.ClearError();
- m_filepath = paths_GetLongPath(m_filepath);
+ m_filepath = paths_GetLongPath(m_filepath.c_str());
- if (_tstati64(m_filepath, &fstats) == 0)
+ if (_tstati64(m_filepath.c_str(), &fstats) == 0)
{
m_filesize = fstats.st_size;
m_statusFetched = 1;
m_filename = filename;
m_filepath = m_filename; // TODO: Make canonical ?
- m_handle = CreateFile(m_filename, dwOpenAccess, dwOpenShareMode, NULL, dwOpenCreationDispostion, 0, 0);
+ m_handle = CreateFile(m_filename.c_str(), dwOpenAccess, dwOpenShareMode, NULL, dwOpenCreationDispostion, 0, 0);
if (m_handle == INVALID_HANDLE_VALUE)
{
LastError(_T("CreateFile"), GetLastError());
// But we don't care since size is set to 0 anyway.
GetFileStatus();
- m_fp = _tfopen(m_filepath, mode);
+ m_fp = _tfopen(m_filepath.c_str(), mode);
if (!m_fp)
return false;
UniError() { ClearError(); }
};
+ virtual ~UniFile() { }
+
virtual bool OpenReadOnly(LPCTSTR filename) = 0;
virtual void Close() = 0;
virtual bool IsOpen() const = 0;
- virtual CString GetFullyQualifiedPath() const = 0;
+ virtual String GetFullyQualifiedPath() const = 0;
virtual const UniError & GetLastUniError() const = 0;
UniLocalFile();
void Clear();
- virtual CString GetFullyQualifiedPath() const { return m_filepath; }
+ virtual String GetFullyQualifiedPath() const { return m_filepath; }
virtual const UniError & GetLastUniError() const { return m_lastError; }
protected:
int m_statusFetched; // 0 not fetched, -1 error, +1 success
__int64 m_filesize;
- CString m_filepath;
- CString m_filename;
+ String m_filepath;
+ String m_filename;
int m_lineno; // current 0-based line of m_current
UniError m_lastError;
bool m_readbom; // whether have tested for BOM
*/
class UniMemFile : public UniLocalFile
{
+ friend class UniMarkdownFile;
public:
UniMemFile();
virtual ~UniMemFile() { Close(); }
#endif
#include "UnicodeString.h"
+#include "Merge.h"
#include "coretools.h"
#ifndef countof
* @param [in] hModule Module's handle.
* @return Module's path.
*/
-CString GetModulePath(HMODULE hModule /* = NULL*/)
+String GetModulePath(HMODULE hModule /* = NULL*/)
{
TCHAR temp[MAX_PATH] = {0};
GetModuleFileName(hModule, temp, MAX_PATH);
* @param [in] fullpath Full path to split.
* @return Path without filename.
*/
-CString GetPathOnly(LPCTSTR fullpath)
+String GetPathOnly(LPCTSTR fullpath)
{
if (!fullpath || !fullpath[0]) return _T("");
String spath;
SplitFilename(fullpath, &spath, 0, 0);
- return spath.c_str();
+ return spath;
}
/**
/**
* @brief Return time displayed appropriately, as string
*/
-CString TimeString(const __int64 * tim)
+String TimeString(const __int64 * tim)
{
+ USES_CONVERSION;
if (!tim) return _T("---");
// _tcsftime does not respect user date customizations from
// Regional Options/Configuration Regional; COleDateTime::Format does so.
// MSVC7 (VC.NET)
COleDateTime odt = *tim;
#endif
- return odt.Format();
+ // If invalid, return DateTime resource string
+ if (odt.GetStatus() == COleDateTime::null)
+ return String();
+ if (odt.GetStatus() == COleDateTime::invalid)
+ return theApp.LoadString(AFX_IDS_INVALID_DATETIME);
+ COleVariant var;
+ // Don't need to trap error. Should not fail due to type mismatch
+ AfxCheckError(VarBstrFromDate(odt.m_dt, LANG_USER_DEFAULT, 0, &V_BSTR(&var)));
+ var.vt = VT_BSTR;
+ return OLE2CT(V_BSTR(&var));
}
long SwapEndian(long val);
short int SwapEndian(short int val);
BOOL MkDirEx(LPCTSTR foldername);
-CString GetModulePath(HMODULE hModule = NULL);
-CString GetPathOnly(LPCTSTR fullpath);
+String GetModulePath(HMODULE hModule = NULL);
+String GetPathOnly(LPCTSTR fullpath);
float RoundMeasure(float measure, float units);
CString LegalizeFileName(LPCTSTR szFileName);
BOOL GetAppDataPath(CString &sAppDataPath);
BOOL GetUserProfilePath(CString &sAppDataPath);
-CString TimeString(const __int64 * tim);
+String TimeString(const __int64 * tim);
void GetDecoratedCmdLine(CString sCmdLine, CString &sDecoratedCmdLine,
CString &sExecutable);
#include "unicoder.h"
#include "multiformatText.h"
#include "files.h"
+#include "paths.h"
#include "UniFile.h"
#include "codepage.h"
LPCTSTR storageForPlugins::GetDestFileName()
{
- if (m_tempFilenameDst.IsEmpty())
+ if (m_tempFilenameDst.empty())
{
- TCHAR tempDir[MAX_PATH] = _T("");
- if (!GetTempPath(countof(tempDir), tempDir))
- return NULL;
-
- if (!GetTempFileName(tempDir, _T ("_WM"), 0, m_tempFilenameDst.GetBuffer(MAX_PATH)))
- {
- m_tempFilenameDst.ReleaseBuffer();
- m_tempFilenameDst.Empty();
- return NULL;
- }
- m_tempFilenameDst.ReleaseBuffer();
+ m_tempFilenameDst = paths_GetTempFileName(paths_GetTempPath(), _T ("_WM"));
}
- return m_tempFilenameDst;
+ return m_tempFilenameDst.c_str();
}
if (m_nChangedValid == m_nChanged)
{
// plugin succeeded, but nothing changed, just delete the new file
- if (!::DeleteFile(m_tempFilenameDst))
+ if (!::DeleteFile(m_tempFilenameDst.c_str()))
{
LogErrorString(Fmt(_T("DeleteFile(%s) failed: %s")
- , m_tempFilenameDst, GetSysError(GetLastError())));
+ , m_tempFilenameDst.c_str(), GetSysError(GetLastError())));
}
// we may reuse the temp filename
// tempFilenameDst.Empty();
m_nChangedValid = m_nChanged;
if (m_bOverwriteSourceFile)
{
- if (!::DeleteFile(m_filename))
+ if (!::DeleteFile(m_filename.c_str()))
{
LogErrorString(Fmt(_T("DeleteFile(%s) failed: %s")
- , m_filename, GetSysError(GetLastError())));
+ , m_filename.c_str(), GetSysError(GetLastError())));
}
- ::MoveFile(m_tempFilenameDst, m_filename);
+ ::MoveFile(m_tempFilenameDst.c_str(), m_filename.c_str());
}
else
{
// for next transformation, we may overwrite/delete the source file
m_bOverwriteSourceFile = TRUE;
}
- m_tempFilenameDst.Empty();
+ m_tempFilenameDst.erase();
}
}
void storageForPlugins::ValidateNewBuffer()
{
if (m_bOverwriteSourceFile)
{
- ::DeleteFile(m_filename);
- ::MoveFile(m_tempFilenameDst, m_filename);
+ ::DeleteFile(m_filename.c_str());
+ ::MoveFile(m_tempFilenameDst.c_str(), m_filename.c_str());
}
else
{
// for next transformation, we may overwrite/delete the source file
m_bOverwriteSourceFile = TRUE;
}
- m_tempFilenameDst.Empty();
+ m_tempFilenameDst.erase();
}
// old memory structures are freed
LPCTSTR storageForPlugins::GetDataFileUnicode()
{
if (m_bCurrentIsFile && m_bCurrentIsUnicode)
- return m_filename;
+ return m_filename.c_str();
MAPPEDFILEDATA fileDataIn = {0};
UINT nchars;
if (m_bCurrentIsFile)
{
// Init filedata struct and open file as memory mapped (in file)
- _tcsncpy(fileDataIn.fileName, m_filename, m_filename.GetLength()+1);
+ _tcsncpy(fileDataIn.fileName, m_filename.c_str(), MAX_PATH);
fileDataIn.bWritable = FALSE;
fileDataIn.dwOpenFlags = OPEN_EXISTING;
BOOL bSuccess = files_openFileMapped(&fileDataIn);
// Init filedata struct and open file as memory mapped (out file)
GetDestFileName();
MAPPEDFILEDATA fileDataOut = {0};
- _tcscpy(fileDataOut.fileName, m_tempFilenameDst);
+ _tcsncpy(fileDataOut.fileName, m_tempFilenameDst.c_str(), MAX_PATH);
fileDataOut.bWritable = TRUE;
fileDataOut.dwOpenFlags = CREATE_ALWAYS;
fileDataOut.dwSize = textForeseenSize + 2;
if ((textRealSize == 0) && (textForeseenSize > 0))
{
// conversion error
- ::DeleteFile(m_tempFilenameDst);
+ ::DeleteFile(m_tempFilenameDst.c_str());
return NULL;
}
ValidateInternal(TRUE, TRUE);
- return m_filename;
+ return m_filename.c_str();
}
if (m_bCurrentIsFile)
{
// Init filedata struct and open file as memory mapped (in file)
- _tcscpy(fileDataIn.fileName, m_filename);
+ _tcsncpy(fileDataIn.fileName, m_filename.c_str(), MAX_PATH);
fileDataIn.bWritable = FALSE;
fileDataIn.dwOpenFlags = OPEN_EXISTING;
BOOL bSuccess = files_openFileMapped(&fileDataIn);
LPCTSTR storageForPlugins::GetDataFileAnsi()
{
if (m_bCurrentIsFile && !m_bCurrentIsUnicode)
- return m_filename;
+ return m_filename.c_str();
MAPPEDFILEDATA fileDataIn = {0};
UINT nchars;
if (m_bCurrentIsFile)
{
// Init filedata struct and open file as memory mapped (in file)
- _tcsncpy(fileDataIn.fileName, m_filename, m_filename.GetLength()+1);
+ _tcsncpy(fileDataIn.fileName, m_filename.c_str(), MAX_PATH);
fileDataIn.bWritable = FALSE;
fileDataIn.dwOpenFlags = OPEN_EXISTING;
BOOL bSuccess = files_openFileMapped(&fileDataIn);
// Init filedata struct and open file as memory mapped (out file)
GetDestFileName();
MAPPEDFILEDATA fileDataOut = {0};
- _tcscpy(fileDataOut.fileName, m_tempFilenameDst);
+ _tcsncpy(fileDataOut.fileName, m_tempFilenameDst.c_str(), MAX_PATH);
fileDataOut.bWritable = TRUE;
fileDataOut.dwOpenFlags = CREATE_ALWAYS;
fileDataOut.dwSize = textForeseenSize;
if ((textRealSize == 0) && (textForeseenSize > 0))
{
// conversion error
- ::DeleteFile(m_tempFilenameDst);
+ ::DeleteFile(m_tempFilenameDst.c_str());
return NULL;
}
ValidateInternal(TRUE, FALSE);
- return m_filename;
+ return m_filename.c_str();
}
if (m_bCurrentIsFile)
{
// Init filedata struct and open file as memory mapped (in file)
- _tcscpy(fileDataIn.fileName, m_filename);
+ _tcsncpy(fileDataIn.fileName, m_filename.c_str(), MAX_PATH);
fileDataIn.bWritable = FALSE;
fileDataIn.dwOpenFlags = OPEN_EXISTING;
BOOL bSuccess = files_openFileMapped(&fileDataIn);
}
-BOOL UnicodeFileToOlechar(CString & filepath, LPCTSTR filepathDst, int & nFileChanged)
+BOOL UnicodeFileToOlechar(LPCTSTR filepath, LPCTSTR filepathDst, int & nFileChanged)
{
UniMemFile ufile;
if (!ufile.OpenReadOnly(filepath) || !ufile.ReadBom())
// Init filedataIn struct and open file as memory mapped (input)
BOOL bSuccess;
MAPPEDFILEDATA fileDataIn = {0};
- _tcsncpy(fileDataIn.fileName, filepath, filepath.GetLength()+1);
+ _tcsncpy(fileDataIn.fileName, filepath, MAX_PATH);
fileDataIn.bWritable = FALSE;
fileDataIn.dwOpenFlags = OPEN_EXISTING;
bSuccess = files_openFileMapped(&fileDataIn);
* Returns FALSE if file has Unicode BOM but is not UCS-2LE.
* Returns TRUE if file is not Unicode, or if converted file successfully.
*/
-BOOL OlecharToUTF8(CString & filepath, LPCTSTR filepathDst, int & nFileChanged, BOOL bWriteBOM)
+BOOL OlecharToUTF8(LPCTSTR filepath, LPCTSTR filepathDst, int & nFileChanged, BOOL bWriteBOM)
{
UniMemFile ufile;
if (!ufile.OpenReadOnly(filepath) || !ufile.ReadBom())
// Init filedataIn struct and open file as memory mapped (input)
BOOL bSuccess;
MAPPEDFILEDATA fileDataIn = {0};
- _tcsncpy(fileDataIn.fileName, filepath, filepath.GetLength()+1);
+ _tcsncpy(fileDataIn.fileName, filepath, MAX_PATH);
fileDataIn.bWritable = FALSE;
fileDataIn.dwOpenFlags = OPEN_EXISTING;
bSuccess = files_openFileMapped(&fileDataIn);
public:
~storageForPlugins()
{
- if (!m_tempFilenameDst)
- ::DeleteFile(m_tempFilenameDst);
+ if (!m_tempFilenameDst.empty()) // "!m_tempFilenameDst" means "never"
+ ::DeleteFile(m_tempFilenameDst.c_str());
m_bstr.Empty();
m_array.Clear();
}
/// Initial load
void SetDataFileUnicode(LPCTSTR filename, BOOL bOverwrite = FALSE);
/// Final save, same format as the original file
- BOOL SaveAsFile(CString & filename)
+ BOOL SaveAsFile(String & filename)
{
LPCTSTR newFilename;
if (m_bOriginalIsUnicode)
}
/// Get the last valid file after an error
/// Warning : the format may be different from the original one
- void GetLastValidFile(CString & filename)
+ void GetLastValidFile(String & filename)
{
- if (!m_tempFilenameDst)
- ::DeleteFile(m_tempFilenameDst);
- m_tempFilenameDst.Empty();
+ if (!m_tempFilenameDst.empty())
+ ::DeleteFile(m_tempFilenameDst.c_str());
+ m_tempFilenameDst.erase();
filename = this->m_filename;
}
// data storage when mode is BUFFER ANSI
COleSafeArray m_array;
// data storage when mode is FILE
- CString m_filename;
+ String m_filename;
// error during conversion ?
BOOL m_bError;
// codepage for ANSI mode
// temporary number of transformations, transformed by caller
int m_nChanged;
// temporary destination filename
- CString m_tempFilenameDst;
+ String m_tempFilenameDst;
};
// other conversion functions
/// Convert any unicode file to UCS-2LE
-BOOL UnicodeFileToOlechar(CString & filepath, LPCTSTR filepathDst, int & nFileChanged);
+BOOL UnicodeFileToOlechar(LPCTSTR filepath, LPCTSTR filepathDst, int & nFileChanged);
/// Convert UCS-2LE file to UTF-8 (for diffutils)
-BOOL OlecharToUTF8(CString & filepath, LPCTSTR filepathDst, int & nFileChanged, BOOL bWriteBOM);
+BOOL OlecharToUTF8(LPCTSTR filepath, LPCTSTR filepathDst, int & nFileChanged, BOOL bWriteBOM);
#endif //__MULTIFORMATTEXT_H__
\ No newline at end of file