diff options
author | Underground78 <underground78@users.sourceforge.net> | 2014-10-29 12:51:41 +0300 |
---|---|---|
committer | Underground78 <underground78@users.sourceforge.net> | 2014-11-11 23:55:02 +0300 |
commit | 20f8c73bf12927986ceaf6908bf2b41014de6fa1 (patch) | |
tree | 7435b875fa852db103c9442060767aa1708bf9a8 | |
parent | ecdbad0c0dba3ebb9e86f1aaf4d209d5025e5fa1 (diff) |
DSUtil: Remove duplicated function GetProgramPath.
-rw-r--r-- | src/DSUtil/WinAPIUtils.cpp | 14 | ||||
-rw-r--r-- | src/DSUtil/WinAPIUtils.h | 2 | ||||
-rw-r--r-- | src/mpc-hc/AboutDlg.cpp | 3 | ||||
-rw-r--r-- | src/mpc-hc/FGFilterLAV.cpp | 10 | ||||
-rw-r--r-- | src/mpc-hc/FileAssoc.cpp | 22 | ||||
-rw-r--r-- | src/mpc-hc/MainFrm.cpp | 4 | ||||
-rw-r--r-- | src/mpc-hc/PPageWebServer.cpp | 6 | ||||
-rw-r--r-- | src/mpc-hc/PlayerToolBar.cpp | 8 | ||||
-rw-r--r-- | src/mpc-hc/Translations.cpp | 2 | ||||
-rw-r--r-- | src/mpc-hc/WebServer.cpp | 4 |
10 files changed, 29 insertions, 46 deletions
diff --git a/src/DSUtil/WinAPIUtils.cpp b/src/DSUtil/WinAPIUtils.cpp index 44d9884f7..d16658acb 100644 --- a/src/DSUtil/WinAPIUtils.cpp +++ b/src/DSUtil/WinAPIUtils.cpp @@ -268,20 +268,6 @@ bool ExploreToFile(LPCTSTR path) return success;
}
-CString GetProgramPath(bool bWithExecutableName /*= false*/)
-{
- CString path;
-
- DWORD dwLength = ::GetModuleFileName(nullptr, path.GetBuffer(MAX_PATH), MAX_PATH);
- path.ReleaseBuffer((int)dwLength);
-
- if (!bWithExecutableName) {
- path = path.Left(path.ReverseFind(_T('\\')) + 1);
- }
-
- return path;
-}
-
CoInitializeHelper::CoInitializeHelper()
{
HRESULT res = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
diff --git a/src/DSUtil/WinAPIUtils.h b/src/DSUtil/WinAPIUtils.h index 4673f842d..4ebaa40d2 100644 --- a/src/DSUtil/WinAPIUtils.h +++ b/src/DSUtil/WinAPIUtils.h @@ -40,8 +40,6 @@ bool ExploreToFile(LPCTSTR path); HRESULT FileDelete(CString file, HWND hWnd, bool recycle = true);
-CString GetProgramPath(bool bWithExecutableName = false);
-
class CoInitializeHelper
{
public:
diff --git a/src/mpc-hc/AboutDlg.cpp b/src/mpc-hc/AboutDlg.cpp index ef013258d..3759655f2 100644 --- a/src/mpc-hc/AboutDlg.cpp +++ b/src/mpc-hc/AboutDlg.cpp @@ -28,7 +28,6 @@ #include "FileVersionInfo.h"
#include "VersionInfo.h"
#include "SysVersion.h"
-#include "WinAPIUtils.h"
#include "PathUtils.h"
#include <afxole.h>
@@ -78,7 +77,7 @@ BOOL CAboutDlg::OnInitDialog() #endif
// Build the path to Authors.txt
- m_AuthorsPath = GetProgramPath() + _T("Authors.txt");
+ m_AuthorsPath = PathUtils::CombinePaths(PathUtils::GetProgramPath(), _T("Authors.txt"));
// Check if the file exists
if (PathUtils::Exists(m_AuthorsPath)) {
// If it does, we make the filename clickable
diff --git a/src/mpc-hc/FGFilterLAV.cpp b/src/mpc-hc/FGFilterLAV.cpp index 9648e433b..7c662f1bc 100644 --- a/src/mpc-hc/FGFilterLAV.cpp +++ b/src/mpc-hc/FGFilterLAV.cpp @@ -24,7 +24,7 @@ #include "MainFrm.h"
#include "DSUtil.h"
#include "FileVersionInfo.h"
-#include "WinAPIUtils.h"
+#include "PathUtils.h"
#include "SysVersion.h"
#include "AllocatorCommon7.h"
#include "AllocatorCommon.h"
@@ -65,21 +65,21 @@ CFGFilterLAV::CFGFilterLAV(const CLSID& clsid, CString path, CStringW name, bool CString CFGFilterLAV::GetFilterPath(LAVFILTER_TYPE filterType)
{
// Default path
- CString filterPath = GetProgramPath() + LAVFILTERS_DIR;
+ CString filterPath = PathUtils::CombinePaths(PathUtils::GetProgramPath(), LAVFILTERS_DIR);
CLSID filterCLSID;
switch (filterType) {
case SPLITTER:
case SPLITTER_SOURCE:
- filterPath += CFGFilterLAVSplitterBase::filename;
+ filterPath = PathUtils::CombinePaths(filterPath, CFGFilterLAVSplitterBase::filename);
filterCLSID = GUID_LAVSplitter;
break;
case VIDEO_DECODER:
- filterPath += CFGFilterLAVVideo::filename;
+ filterPath = PathUtils::CombinePaths(filterPath, CFGFilterLAVVideo::filename);
filterCLSID = GUID_LAVVideo;
break;
case AUDIO_DECODER:
- filterPath += CFGFilterLAVAudio::filename;
+ filterPath = PathUtils::CombinePaths(filterPath, CFGFilterLAVAudio::filename);
filterCLSID = GUID_LAVAudio;
break;
default:
diff --git a/src/mpc-hc/FileAssoc.cpp b/src/mpc-hc/FileAssoc.cpp index 529270047..c33f237d7 100644 --- a/src/mpc-hc/FileAssoc.cpp +++ b/src/mpc-hc/FileAssoc.cpp @@ -24,7 +24,7 @@ #include "FileAssoc.h"
#include "resource.h"
#include "SysVersion.h"
-#include "WinAPIUtils.h"
+#include "PathUtils.h"
// TODO: change this along with the root key for settings and the mutex name to
@@ -64,13 +64,13 @@ void CFileAssoc::IconLib::SaveVersion() const }
CFileAssoc::CFileAssoc()
- : m_iconLibPath(GetProgramPath() + _T("mpciconlib.dll"))
+ : m_iconLibPath(PathUtils::CombinePaths(PathUtils::GetProgramPath(), _T("mpciconlib.dll")))
, m_strRegisteredAppName(_T("Media Player Classic"))
, m_strOldAssocKey(_T("PreviousRegistration"))
, m_strRegisteredAppKey(_T("Software\\Clients\\Media\\Media Player Classic\\Capabilities"))
, m_strRegAppFileAssocKey(_T("Software\\Clients\\Media\\Media Player Classic\\Capabilities\\FileAssociations"))
- , m_strOpenCommand(_T("\"") + GetProgramPath(true) + _T("\" \"%1\""))
- , m_strEnqueueCommand(_T("\"") + GetProgramPath(true) + _T("\" /add \"%1\""))
+ , m_strOpenCommand(_T("\"") + PathUtils::GetProgramPath(true) + _T("\" \"%1\""))
+ , m_strEnqueueCommand(_T("\"") + PathUtils::GetProgramPath(true) + _T("\" /add \"%1\""))
, m_bNoRecentDocs(false)
, m_checkIconsAssocInactiveEvent(TRUE, TRUE) // initially set, manual reset
{
@@ -137,7 +137,7 @@ bool CFileAssoc::RegisterApp() bool success = false;
if (m_pAAR) {
- CString appIcon = "\"" + GetProgramPath(true) + "\",0";
+ CString appIcon = "\"" + PathUtils::GetProgramPath(true) + "\",0";
// Register MPC-HC for the windows "Default application" manager
CRegKey key;
@@ -191,7 +191,7 @@ bool CFileAssoc::Register(CString ext, CString strLabel, bool bRegister, bool bR key.DeleteValue(_T("NoRecentDocs"));
}
- CString appIcon = "\"" + GetProgramPath(true) + "\",0";
+ CString appIcon = "\"" + PathUtils::GetProgramPath(true) + "\",0";
// Add to playlist option
if (bRegisterContextMenuEntries) {
@@ -526,7 +526,7 @@ bool CFileAssoc::RegisterFolderContextMenuEntries(bool bRegister) if (bRegister) {
success = false;
- CString appIcon = "\"" + GetProgramPath(true) + "\",0";
+ CString appIcon = "\"" + PathUtils::GetProgramPath(true) + "\",0";
if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".enqueue"))) {
key.SetStringValue(nullptr, ResStr(IDS_ADD_TO_PLAYLIST));
@@ -577,7 +577,7 @@ bool CFileAssoc::AreRegisteredFolderContextMenuEntries() const bool CFileAssoc::RegisterAutoPlay(autoplay_t ap, bool bRegister)
{
- CString exe = GetProgramPath(true);
+ CString exe = PathUtils::GetProgramPath(true);
size_t i = (size_t)ap;
if (i >= m_handlers.size()) {
@@ -632,7 +632,7 @@ bool CFileAssoc::IsAutoPlayRegistered(autoplay_t ap) const {
ULONG len;
TCHAR buff[MAX_PATH];
- CString exe = GetProgramPath(true);
+ CString exe = PathUtils::GetProgramPath(true);
size_t i = (size_t)ap;
if (i >= m_handlers.size()) {
@@ -727,7 +727,7 @@ bool CFileAssoc::ReAssocIcons(const CAtlList<CString>& exts) }
iconLib->SaveVersion();
- const CString progPath = GetProgramPath(true);
+ const CString progPath = PathUtils::GetProgramPath(true);
CRegKey key;
@@ -804,7 +804,7 @@ void CFileAssoc::CheckIconsAssocThread() TaskDialogIndirect(&config, &nButtonPressed, nullptr, nullptr);
if (IDYES == nButtonPressed) {
- AfxGetMyApp()->RunAsAdministrator(GetProgramPath(true), _T("/iconsassoc"), true);
+ AfxGetMyApp()->RunAsAdministrator(PathUtils::GetProgramPath(true), _T("/iconsassoc"), true);
}
}
diff --git a/src/mpc-hc/MainFrm.cpp b/src/mpc-hc/MainFrm.cpp index 2fcf600ce..ec5ec9012 100644 --- a/src/mpc-hc/MainFrm.cpp +++ b/src/mpc-hc/MainFrm.cpp @@ -8958,7 +8958,7 @@ void CMainFrame::PlayFavoriteFile(CString fav) // All you have to do then is plug in your 500 gb drive, full with movies and/or music, start MPC-HC (from the 500 gb drive) with a preloaded playlist and press play.
if (bRelativeDrive) {
// Get the drive MPC-HC is on and apply it to the path list
- CString exePath = GetProgramPath(true);
+ CString exePath = PathUtils::GetProgramPath(true);
CPath exeDrive(exePath);
@@ -14332,7 +14332,7 @@ void CMainFrame::ShowOptions(int idPage/* = 0*/) // Request MPC-HC to close itself
SendMessage(WM_CLOSE);
// and immediately reopen
- ShellExecute(nullptr, _T("open"), GetProgramPath(true), _T("/reset"), nullptr, SW_SHOWNORMAL);
+ ShellExecute(nullptr, _T("open"), PathUtils::GetProgramPath(true), _T("/reset"), nullptr, SW_SHOWNORMAL);
break;
default:
ASSERT(iRes > 0 && iRes != CPPageSheet::APPLY_LANGUAGE_CHANGE);
diff --git a/src/mpc-hc/PPageWebServer.cpp b/src/mpc-hc/PPageWebServer.cpp index 8c5d4a95b..8be560c34 100644 --- a/src/mpc-hc/PPageWebServer.cpp +++ b/src/mpc-hc/PPageWebServer.cpp @@ -24,7 +24,7 @@ #include "MainFrm.h"
#include "PPageWebServer.h"
#include "SysVersion.h"
-#include "WinAPIUtils.h"
+#include "PathUtils.h"
#include <afxglobals.h>
@@ -152,7 +152,7 @@ CString CPPageWebServer::GetCurWebRoot() WebRoot.Replace('/', '\\');
CPath path;
- path.Combine(GetProgramPath(), WebRoot);
+ path.Combine(PathUtils::GetProgramPath(), WebRoot);
return path.IsDirectory() ? (LPCTSTR)path : _T("");
}
@@ -241,7 +241,7 @@ void CPPageWebServer::OnBnClickedButton1() CString dir = GetCurWebRoot();
if (PickDir(dir)) {
CPath path;
- if (path.RelativePathTo(GetProgramPath(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY)) {
+ if (path.RelativePathTo(PathUtils::GetProgramPath(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY)) {
dir = (LPCTSTR)path;
}
m_WebRoot = dir;
diff --git a/src/mpc-hc/PlayerToolBar.cpp b/src/mpc-hc/PlayerToolBar.cpp index e81c35785..f74b0926d 100644 --- a/src/mpc-hc/PlayerToolBar.cpp +++ b/src/mpc-hc/PlayerToolBar.cpp @@ -27,7 +27,7 @@ #include "MPCPngImage.h"
#include "PlayerToolBar.h"
#include "MainFrm.h"
-#include "WinAPIUtils.h"
+#include "PathUtils.h"
// CPlayerToolBar
@@ -48,12 +48,12 @@ CPlayerToolBar::~CPlayerToolBar() bool CPlayerToolBar::LoadExternalToolBar(CImage* image)
{
bool success = true;
- CString path = GetProgramPath();
+ CString path = PathUtils::GetProgramPath();
// Try to load an external PNG toolbar first
- if (FAILED(image->Load(path + _T("toolbar.png")))) {
+ if (FAILED(image->Load(PathUtils::CombinePaths(path, _T("toolbar.png"))))) {
// If it fails, try to load an external BMP toolbar
- if (FAILED(image->Load(path + _T("toolbar.bmp")))) {
+ if (FAILED(image->Load(PathUtils::CombinePaths(path, _T("toolbar.bmp"))))) {
if (AfxGetMyApp()->GetAppDataPath(path)) {
// Try to load logo from AppData path
if (FAILED(image->Load(path + _T("\\toolbar.png")))) {
diff --git a/src/mpc-hc/Translations.cpp b/src/mpc-hc/Translations.cpp index ca16bd7b1..8c24c199c 100644 --- a/src/mpc-hc/Translations.cpp +++ b/src/mpc-hc/Translations.cpp @@ -86,7 +86,7 @@ std::list<const Translations::LanguageResource> Translations::GetAvailableLangua CString appPath = PathUtils::GetProgramPath(); for (auto& lr : languageResources) { - if (0 == lr.localeID || PathUtils::Exists(appPath + lr.dllPath)) { + if (0 == lr.localeID || PathUtils::Exists(PathUtils::CombinePaths(appPath, lr.dllPath))) { availableResources.emplace_back(lr); } } diff --git a/src/mpc-hc/WebServer.cpp b/src/mpc-hc/WebServer.cpp index ae46994c1..9cd51e007 100644 --- a/src/mpc-hc/WebServer.cpp +++ b/src/mpc-hc/WebServer.cpp @@ -29,7 +29,7 @@ #include "WebClientSocket.h"
#include "WebServer.h"
#include "VersionInfo.h"
-#include "WinAPIUtils.h"
+#include "PathUtils.h"
CAtlStringMap<CWebServer::RequestHandler, CStringA> CWebServer::m_internalpages;
@@ -40,7 +40,7 @@ CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort) : m_pMainFrame(pMainFrame)
, m_nPort(nPort)
{
- m_webroot = CPath(GetProgramPath());
+ m_webroot = CPath(PathUtils::GetProgramPath());
const CAppSettings& s = AfxGetAppSettings();
CString WebRoot = s.strWebRoot;
|