#include "PreferencesDlg.h"
#include "MainFrm.h"
#include "Merge.h"
-#include "paths.h" //paths_SplitFilename()
+#include "paths.h"
#include "FileOrFolderSelect.h"
#ifdef _DEBUG
{
// Add settings file extension if it is missing
// So we allow 'filename.otherext' but add extension for 'filename'
- String extension;
- paths_SplitFilename(settingsFile, NULL, NULL, &extension);
- if (extension.empty())
+ if (paths_FindExtension(settingsFile).empty())
settingsFile += _T(".ini");
// Save all new settings before exporting
if (DOES_NOT_EXIST != paths_DoesPathExist(szOldFileName))
{
- String sFullName;
-
- paths_SplitFilename(szOldFileName, &sFullName, NULL, NULL);
- sFullName = paths_ConcatPath(sFullName, szNewFileName);
+ String sFullName = paths_ConcatPath(paths_GetPathOnly(szOldFileName), szNewFileName);
// No need to rename if new file already exist.
if ((sFullName != szOldFileName) ||
*/
void DirItem::SetFile(const String &fullPath)
{
- String ext;
- paths_SplitFilename(fullPath, &path, &filename, &ext);
- filename += _T(".");
- filename += ext;
+ filename = paths_FindFileName(fullPath);
}
/**
if (SelectFile(GetSafeHwnd(), s, path.c_str(), _("Locate filter file to install"), _("File Filters (*.flt)|*.flt|All Files (*.*)|*.*||"),
TRUE))
{
- String sfile, sext;
- paths_SplitFilename(s, NULL, &sfile, &sext);
- String filename = sfile;
- filename += _T(".");
- filename += sext;
- userPath = paths_ConcatPath(userPath, filename);
+ userPath = paths_ConcatPath(userPath, paths_FindFileName(s));
if (!CopyFile(s.c_str(), userPath.c_str(), TRUE))
{
// If file already exists, ask from user
else
{
for (int nBuffer = 0; nBuffer < m_filePaths.GetSize(); nBuffer++)
- {
- if (!m_strDesc[nBuffer].empty())
- sFileName[nBuffer] = m_strDesc[nBuffer];
- else
- {
- String file;
- String ext;
- paths_SplitFilename(m_filePaths[nBuffer], NULL, &file, &ext);
- sFileName[nBuffer] += file.c_str();
- if (!ext.empty())
- {
- sFileName[nBuffer] += _T(".");
- sFileName[nBuffer] += ext.c_str();
- }
- }
- }
+ sFileName[nBuffer] = !m_strDesc[nBuffer].empty() ? m_strDesc[nBuffer] : paths_FindFileName(m_filePaths[nBuffer]);
if (std::count(&sFileName[0], &sFileName[0] + m_nBuffers, sFileName[0]) == m_nBuffers)
sTitle = sFileName[0] + string_format(_T(" x %d"), m_nBuffers);
else
else
{
for (int nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
- {
- if (!m_strDesc[nBuffer].empty())
- sFileName[nBuffer] = m_strDesc[nBuffer];
- else
- {
- String file;
- String ext;
- paths_SplitFilename(m_filePaths[nBuffer], NULL, &file, &ext);
- sFileName[nBuffer] += file;
- if (!ext.empty())
- {
- sFileName[nBuffer] += _T(".");
- sFileName[nBuffer] += ext;
- }
- }
- }
+ sFileName[nBuffer] = !m_strDesc[nBuffer].empty() ? m_strDesc[nBuffer] : paths_FindFileName(m_filePaths[nBuffer]);
if (std::count(&sFileName[0], &sFileName[0] + m_nBuffers, sFileName[0]) == m_nBuffers)
sTitle = sFileName[0] + string_format(_T(" x %d"), m_nBuffers);
else
if (ShowDialog(&dlgPatch))
{
- String path;
- paths_SplitFilename(dlgPatch.m_fileResult, &path, NULL, NULL);
- if (!paths_CreateIfNeeded(path))
+ if (!paths_CreateIfNeeded(paths_GetPathOnly(dlgPatch.m_fileResult)))
{
LangMessageBox(IDS_FOLDER_NOTEXIST, MB_OK | MB_ICONSTOP);
return 0;
// Add projectfile extension if it is missing
// So we allow 'filename.otherext' but add extension for 'filename'
- String extension;
- paths_SplitFilename(strProjectFileName, NULL, NULL, &extension);
- if (extension.empty())
- {
- strProjectFileName += _T(".");
- strProjectFileName += _("WinMerge");
- }
+ if (paths_FindExtension(strProjectFileName).empty())
+ strProjectFileName += _T(".WinMerge");
// get the path part from the filename
strProjectPath = paths_GetParentPath(strProjectFileName);