diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2014-10-30 20:06:37 +0300 |
---|---|---|
committer | Kacper Michajłow <kasper93@gmail.com> | 2014-11-11 23:00:05 +0300 |
commit | 645ab11f684963ec4a609f9f8788702e36e3dc78 (patch) | |
tree | 70eba08d8154c59f9d9be0215f7928794235f722 | |
parent | 7656ce0de6195bc5c94b9b04f938fceeef4482c3 (diff) |
Move StripPath to PathUtils and clarify why we need custom version.
-rw-r--r-- | src/DSUtil/PathUtils.cpp | 10 | ||||
-rw-r--r-- | src/DSUtil/PathUtils.h | 1 | ||||
-rw-r--r-- | src/mpc-hc/MainFrm.cpp | 13 | ||||
-rw-r--r-- | src/mpc-hc/Playlist.cpp | 12 |
4 files changed, 15 insertions, 21 deletions
diff --git a/src/DSUtil/PathUtils.cpp b/src/DSUtil/PathUtils.cpp index f66676ca8..e382083f0 100644 --- a/src/DSUtil/PathUtils.cpp +++ b/src/DSUtil/PathUtils.cpp @@ -132,6 +132,16 @@ namespace PathUtils return CString(path).Trim(_T("\"")); } + CString StripPathOrUrl(LPCTSTR path) + { + // Replacement for CPath::StripPath which works fine also for URLs + CString p = path; + p.Replace('\\', '/'); + p.TrimRight('/'); + p = p.Mid(p.ReverseFind('/') + 1); + return (p.IsEmpty() ? path : p); + } + bool IsInDir(LPCTSTR path, LPCTSTR dir) { return !!CPath(path).IsPrefix(dir); diff --git a/src/DSUtil/PathUtils.h b/src/DSUtil/PathUtils.h index 9c37a2155..bec04b99f 100644 --- a/src/DSUtil/PathUtils.h +++ b/src/DSUtil/PathUtils.h @@ -32,6 +32,7 @@ namespace PathUtils CString CombinePaths(LPCTSTR dir, LPCTSTR path); CString FilterInvalidCharsFromFileName(LPCTSTR fn, TCHAR replacementChar = _T('_')); CString Unquote(LPCTSTR path); + CString StripPathOrUrl(LPCTSTR path); bool IsInDir(LPCTSTR path, LPCTSTR dir); CString ToRelative(LPCTSTR dir, const LPCTSTR path, bool* pbRelative = nullptr); bool IsRelative(LPCTSTR path); diff --git a/src/mpc-hc/MainFrm.cpp b/src/mpc-hc/MainFrm.cpp index c27e67719..2e1b300d8 100644 --- a/src/mpc-hc/MainFrm.cpp +++ b/src/mpc-hc/MainFrm.cpp @@ -12790,15 +12790,6 @@ void CMainFrame::SetupVideoStreamsSubMenu() }
}
-static CString StripPath(CString path)
-{
- CString p = path;
- p.Replace('\\', '/');
- p.TrimRight('/');
- p = p.Mid(p.ReverseFind('/') + 1);
- return (p.IsEmpty() ? path : p);
-}
-
void CMainFrame::SetupJumpToSubMenus(CMenu* parentMenu /*= nullptr*/, int iInsertPos /*= -1*/)
{
auto emptyMenu = [&](CMenu & menu) {
@@ -12853,7 +12844,7 @@ void CMainFrame::SetupJumpToSubMenus(CMenu* parentMenu /*= nullptr*/, int iInser UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
CHdmvClipInfo::PlaylistItem Item = m_MPLSPlaylist.GetNext(pos);
CString time = _T("[") + ReftimeToString2(Item.Duration()) + _T("]");
- CString name = StripPath(Item.m_strFileName);
+ CString name = PathUtils::StripPathOrUrl(Item.m_strFileName);
if (name == m_wndPlaylistBar.m_pl.GetHead().GetLabel()) {
idSelected = id;
@@ -16460,7 +16451,7 @@ CString CMainFrame::GetFileName() }
}
- return StripPath(path);
+ return PathUtils::StripPathOrUrl(path);
}
CString CMainFrame::GetCaptureTitle()
diff --git a/src/mpc-hc/Playlist.cpp b/src/mpc-hc/Playlist.cpp index 52e183cd4..5450ddd7b 100644 --- a/src/mpc-hc/Playlist.cpp +++ b/src/mpc-hc/Playlist.cpp @@ -22,6 +22,7 @@ #include "stdafx.h"
#include "mplayerc.h"
#include "Playlist.h"
+#include "PathUtils.h"
#include "SettingsDefines.h"
//
@@ -83,15 +84,6 @@ POSITION CPlaylistItem::FindFile(LPCTSTR path) return nullptr;
}
-static CString StripPath(CString path)
-{
- CString p = path;
- p.Replace('\\', '/');
- p.TrimRight('/');
- p = p.Mid(p.ReverseFind('/') + 1);
- return (p.IsEmpty() ? path : p);
-}
-
CString CPlaylistItem::GetLabel(int i)
{
CString str;
@@ -100,7 +92,7 @@ CString CPlaylistItem::GetLabel(int i) if (!m_label.IsEmpty()) {
str = m_label;
} else if (!m_fns.IsEmpty()) {
- str = StripPath(m_fns.GetHead());
+ str = PathUtils::StripPathOrUrl(m_fns.GetHead());
}
} else if (i == 1) {
if (m_fInvalid) {
|