mirror of
https://github.com/clsid2/mpc-hc
synced 2026-11-27 18:38:01 +08:00
CTextFile: improve long path support
This commit is contained in:
1 parent
769bdc2daf
commit
c7d0f23681
1 file changed
+11
-1
@@ -44,7 +44,17 @@ CTextFile::CTextFile(enc e)
|
||||
|
||||
bool CTextFile::Open(LPCTSTR lpszFileName)
|
||||
{
|
||||
if (!__super::Open(lpszFileName, modeRead | typeBinary | shareDenyNone)) {
|
||||
wchar_t shortpath[MAX_PATH];
|
||||
LPCTSTR lpszFileNameShort = lpszFileName;
|
||||
if (lstrlen(lpszFileName) > MAX_PATH) {
|
||||
wchar_t shortpath[MAX_PATH];
|
||||
DWORD len = GetShortPathNameW(lpszFileName, shortpath, MAX_PATH);
|
||||
if (len > 0 && len <= MAX_PATH) {
|
||||
lpszFileNameShort = shortpath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!__super::Open(lpszFileNameShort, modeRead | typeBinary | shareDenyNone)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user