Skip to content

Commit

Permalink
Доработка для длинных путей.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksoid1978 committed Sep 15, 2024
1 parent ef765d2 commit 1082486
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
21 changes: 2 additions & 19 deletions src/apps/mplayerc/AppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2477,33 +2477,16 @@ void CAppSettings::SaveFormats()
m_Formats.UpdateData(true);
}

extern BOOL AFXAPI AfxFullPath(LPTSTR lpszPathOut, LPCTSTR lpszFileIn);
extern BOOL AFXAPI AfxComparePath(LPCTSTR lpszPath1, LPCTSTR lpszPath2);

CStringW ParseFileName(const CStringW& param)
{
if (param.Find(L':') < 0) {
// try to convert relative path to full path
CStringW fullPathName;
fullPathName.ReleaseBuffer(GetFullPathNameW(param, MAX_PATH, fullPathName.GetBuffer(MAX_PATH), nullptr));
fullPathName.ReleaseBuffer(GetFullPathNameW(param, 8192, fullPathName.GetBuffer(8192), nullptr));

CFileStatus fs;
if (!fullPathName.IsEmpty() && CFileGetStatus(fullPathName, fs)) {
if (::PathFileExistsW(fullPathName)) {
return fullPathName;
}
} else if (param.GetLength() > MAX_PATH && !::PathIsURLW(param) && !::PathIsUNCW(param)) {
// trying to shorten a long local path
CStringW longpath = StartsWith(param, EXTENDED_PATH_PREFIX) ? param : EXTENDED_PATH_PREFIX + param;
auto length = GetShortPathNameW(longpath, nullptr, 0);
if (length > 0) {
CStringW shortPathName;
length = GetShortPathNameW(longpath, shortPathName.GetBuffer(length), length);
if (length > 0) {
shortPathName.ReleaseBuffer(length);
shortPathName.Delete(0, 4); // remove "\\?\" prefix
return shortPathName;
}
}
}

return param;
Expand Down
2 changes: 1 addition & 1 deletion src/apps/mplayerc/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ BOOL CMainFrame::OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoi
UINT nFiles = ::DragQueryFileW(hDrop, UINT_MAX, nullptr, 0);
for (UINT iFile = 0; iFile < nFiles; iFile++) {
CString fn;
fn.ReleaseBuffer(::DragQueryFileW(hDrop, iFile, fn.GetBuffer(2048), 2048));
fn.ReleaseBuffer(::DragQueryFileW(hDrop, iFile, fn.GetBuffer(8192), 8192));
slFiles.emplace_back(ParseFileName(fn));
}
::DragFinish(hDrop);
Expand Down

0 comments on commit 1082486

Please sign in to comment.