Remove an instance of MAX_PATH limitation

... and avoid manual memory management.

Change-Id: I901cfc1dbede3241d387003c04fa11c1371fa8d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163905
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2024-02-25 19:09:24 +06:00
parent 4114b91610
commit c6e2626f7d
2 changed files with 5 additions and 12 deletions

View file

@ -79,7 +79,7 @@ public:
private:
LONG m_RefCnt;
Filepath_char_t m_szFileName[MAX_PATH];
std::wstring m_FileName;
std::wstring m_FileNameOnly;
};

View file

@ -42,7 +42,6 @@ const std::wstring WSPACE(SPACE);
CInfoTip::CInfoTip(LONG RefCnt) :
m_RefCnt(RefCnt)
{
ZeroMemory(m_szFileName, sizeof(m_szFileName));
InterlockedIncrement(&g_DllRefCnt);
}
@ -197,7 +196,7 @@ COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CInfoTip::GetInfoTip(DWORD /*dwFl
const std::wstring CONST_SPACE(SPACE);
//display File Type, no matter other info is loaded successfully or not.
std::wstring tmpTypeStr = getFileTypeInfo( get_file_name_extension(m_szFileName) );
std::wstring tmpTypeStr = getFileTypeInfo( get_file_name_extension(m_FileName) );
if ( tmpTypeStr != EMPTY_STRING )
{
msg += GetResString(IDS_TYPE_COLON) + CONST_SPACE;
@ -206,7 +205,7 @@ COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CInfoTip::GetInfoTip(DWORD /*dwFl
try
{
CMetaInfoReader meta_info_accessor(m_szFileName);
CMetaInfoReader meta_info_accessor(m_FileName);
//display document title;
if ( meta_info_accessor.getTagData( META_INFO_TITLE ).length() > 0)
@ -265,7 +264,7 @@ COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE CInfoTip::GetInfoTip(DWORD /*dwFl
}
//display file size, no matter other information is loaded successfully or not.
std::wstring tmpSizeStr = getFileSizeInfo( m_szFileName );
std::wstring tmpSizeStr = getFileSizeInfo(m_FileName.c_str());
if ( tmpSizeStr != EMPTY_STRING )
{
msg += L"\n";
@ -327,13 +326,7 @@ HRESULT STDMETHODCALLTYPE CInfoTip::Load(LPCOLESTR pszFileName, DWORD /*dwMode*/
m_FileNameOnly = std::wstring(begin, end);
fname = getShortPathName( fname );
// ZeroMemory because strncpy doesn't '\0'-terminates the destination
// string; reserve the last place in the buffer for the final '\0'
// that's why '(sizeof(m_szFileName) - 1)'
ZeroMemory(m_szFileName, sizeof(m_szFileName));
wcsncpy(m_szFileName, fname.c_str(), (sizeof(m_szFileName)/sizeof(*m_szFileName) - 1));
m_FileName = getShortPathName(fname);
return S_OK;
}