#include "varprop.h"
#include "OptionsMgr.h"
+#define MAX_PATH_FULL 32767
/**
* @brief Split option name to path (in registry) and
* valuename (in registry).
// This just checks if the value exists, LoadValueFromReg() below actually
// loads the value.
DWORD type = 0;
- BYTE dataBuf[MAX_PATH] = {0};
- DWORD size = MAX_PATH;
+ BYTE dataBuf[MAX_PATH_FULL] = {0};
+ DWORD size = MAX_PATH_FULL;
retValReg = RegQueryValueEx(hKey, strValueName.c_str(),
0, &type, dataBuf, &size);
}
else if (value.GetType() == varprop::VT_STRING)
{
- TCHAR strVal[MAX_PATH] = {0};
- GetPrivateProfileString(_T("WinMerge"), pKey, _T(""), strVal, MAX_PATH, filename.c_str());
+ TCHAR strVal[MAX_PATH_FULL] = {0};
+ GetPrivateProfileString(_T("WinMerge"), pKey, _T(""), strVal, MAX_PATH_FULL, filename.c_str());
value.SetString(strVal);
SaveOption(pKey, strVal);
}
// This will tell common file dialog what to show
// and also this will hold its return value
- TCHAR sSelectedFile[MAX_PATH] = {0};
+ TCHAR sSelectedFile[MAX_PATH_FULL] = {0};
// check if specified path is a file
if (initialPath && initialPath[0])
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = sSelectedFile;
- ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFile = MAX_PATH_FULL;
ofn.lpstrInitialDir = initialPath;
ofn.lpstrTitle = title.c_str();
ofn.lpstrFileTitle = NULL;
{
BROWSEINFO bi;
LPITEMIDLIST pidl;
- TCHAR szPath[MAX_PATH] = {0};
+ TCHAR szPath[MAX_PATH_FULL] = {0};
BOOL bRet = FALSE;
String title = stitle;
if (root_path == NULL)
// This will tell common file dialog what to show
// and also this will hold its return value
- TCHAR sSelectedFile[MAX_PATH];
+ TCHAR sSelectedFile[MAX_PATH_FULL];
// check if specified path is a file
if (initialPath && initialPath[0])
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = sSelectedFile;
- ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFile = MAX_PATH_FULL;
ofn.lpstrInitialDir = initialPath;
ofn.lpstrTitle = title.c_str();
ofn.lpstrFileTitle = NULL;
// Expand environment variables:
// Convert "%userprofile%\My Documents" to "C:\Documents and Settings\username\My Documents"
const TCHAR *lpcszPath = szPath.c_str();
- TCHAR expandedPath[_MAX_PATH];
+ TCHAR expandedPath[MAX_PATH_FULL];
if (_tcschr(lpcszPath, '%'))
{
- DWORD dwLen = ExpandEnvironmentStrings(lpcszPath, expandedPath, _MAX_PATH);
- if (dwLen > 0 && dwLen < _MAX_PATH)
+ DWORD dwLen = ExpandEnvironmentStrings(lpcszPath, expandedPath, MAX_PATH_FULL);
+ if (dwLen > 0 && dwLen < MAX_PATH_FULL)
lpcszPath = expandedPath;
}
if (len < 1)
return sPath;
- TCHAR fullPath[_MAX_PATH] = {0};
+ TCHAR fullPath[MAX_PATH_FULL] = {0};
+ TCHAR *pFullPath = &fullPath[0];
TCHAR *lpPart;
// GetFullPathName GetLongPathName
// Expand environment variables:
// Convert "%userprofile%\My Documents" to "C:\Documents and Settings\username\My Documents"
- TCHAR expandedPath[_MAX_PATH];
+ TCHAR expandedPath[MAX_PATH_FULL];
const TCHAR *lpcszPath = sPath.c_str();
if (bExpandEnvs && _tcschr(lpcszPath, '%'))
{
- DWORD dwLen = ExpandEnvironmentStrings(lpcszPath, expandedPath, _MAX_PATH);
- if (dwLen > 0 && dwLen < _MAX_PATH)
+ DWORD dwLen = ExpandEnvironmentStrings(lpcszPath, expandedPath, MAX_PATH_FULL);
+ if (dwLen > 0 && dwLen < MAX_PATH_FULL)
lpcszPath = expandedPath;
}
- DWORD dwLen = GetFullPathName(lpcszPath, _MAX_PATH, fullPath, &lpPart);
- if (dwLen == 0 || dwLen >= _MAX_PATH)
+ DWORD dwLen = GetFullPathName(lpcszPath, MAX_PATH_FULL, fullPath, &lpPart);
+ if (dwLen == 0 || dwLen >= MAX_PATH_FULL)
_tcscpy_safe(fullPath, lpcszPath);
// We are done if this is not a short name.
- if (_tcschr(fullPath, _T('~')) == NULL)
- return fullPath;
+ if (_tcschr(pFullPath, _T('~')) == NULL)
+ return pFullPath;
// We have to do it the hard way because GetLongPathName is not
// available on Win9x and some WinNT 4
if (GetDirName(szPath, sTemp))
return true;
- if (szPath.length() >= _MAX_PATH)
+ if (szPath.length() >= MAX_PATH_FULL)
return false;
// Expand environment variables:
// Convert "%userprofile%\My Documents" to "C:\Documents and Settings\username\My Documents"
- TCHAR fullPath[_MAX_PATH];
+ TCHAR fullPath[MAX_PATH_FULL];
if (_tcschr(szPath.c_str(), '%'))
{
- DWORD dwLen = ExpandEnvironmentStrings(szPath.c_str(), fullPath, _MAX_PATH);
- if (dwLen == 0 || dwLen >= _MAX_PATH)
+ DWORD dwLen = ExpandEnvironmentStrings(szPath.c_str(), fullPath, MAX_PATH_FULL);
+ if (dwLen == 0 || dwLen >= MAX_PATH_FULL)
_tcscpy_safe(fullPath, szPath.c_str());
}
else
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*) &ppf);
if (SUCCEEDED(hres))
{
- WCHAR wsz[MAX_PATH];
+ WCHAR wsz[MAX_PATH_FULL];
#ifdef _UNICODE
_tcscpy_safe(wsz, inFile.c_str());
#else
- ::MultiByteToWideChar(CP_ACP, 0, inFile.c_str(), -1, wsz, MAX_PATH);
+ ::MultiByteToWideChar(CP_ACP, 0, inFile.c_str(), -1, wsz, MAX_PATH_FULL);
#endif
// Load shortcut
if (SUCCEEDED(hres))
{
// find the path from that
- TCHAR buf[MAX_PATH] = {0};
- psl->GetPath(buf, MAX_PATH, NULL, SLGP_UNCPRIORITY);
+ TCHAR buf[MAX_PATH_FULL] = {0};
+ psl->GetPath(buf, MAX_PATH_FULL, NULL, SLGP_UNCPRIORITY);
outFile = buf;
}
ppf->Release();