OSDN Git Service

Use paths_FindFileName() or paths_GetPathOnly() instead of paths_SplitFileName()
authorsdottaka <none@none>
Sat, 31 Aug 2013 18:16:49 +0000 (03:16 +0900)
committersdottaka <none@none>
Sat, 31 Aug 2013 18:16:49 +0000 (03:16 +0900)
Src/Common/PreferencesDlg.cpp
Src/DirActions.cpp
Src/DirItem.cpp
Src/FileFiltersDlg.cpp
Src/HexMergeDoc.cpp
Src/MergeDoc.cpp
Src/PatchTool.cpp
Src/ProjectFilePathsDlg.cpp

index e8d8b88..36c165c 100644 (file)
@@ -19,7 +19,7 @@
 #include "PreferencesDlg.h"
 #include "MainFrm.h"
 #include "Merge.h"
-#include "paths.h" //paths_SplitFilename()
+#include "paths.h"
 #include "FileOrFolderSelect.h"
 
 #ifdef _DEBUG
@@ -338,9 +338,7 @@ void CPreferencesDlg::OnExportButton()
        {
                // 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
index 4f4eddb..3bde090 100644 (file)
@@ -1209,10 +1209,7 @@ bool RenameOnSameDir(const String& szOldFileName, const String& szNewFileName)
 
        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) ||
index ce0290d..8584a78 100644 (file)
  */
 void DirItem::SetFile(const String &fullPath)
 {
-       String ext;
-       paths_SplitFilename(fullPath, &path, &filename, &ext);
-       filename += _T(".");
-       filename += ext;
+       filename = paths_FindFileName(fullPath);
 }
 
 /**
index 03568d2..f931f81 100644 (file)
@@ -564,12 +564,7 @@ void FileFiltersDlg::OnBnClickedFilterfileInstall()
        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
index 07e3f5d..64f18cc 100644 (file)
@@ -577,22 +577,7 @@ void CHexMergeDoc::SetTitle(LPCTSTR lpszTitle)
        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
index 8395a75..938e1de 100644 (file)
@@ -2960,22 +2960,7 @@ void CMergeDoc::SetTitle(LPCTSTR lpszTitle)
        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
index 72bc511..4c4545d 100644 (file)
@@ -111,9 +111,7 @@ int CPatchTool::CreatePatch()
 
        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;
index 83753f2..4dbd61a 100644 (file)
@@ -234,13 +234,8 @@ String ProjectFilePathsDlg::AskProjectFileName(bool bOpen)
 
        // 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);