MCPcopy Create free account
hub / github.com/ConEmu/ConEmu / apiGetFullPathName

Function apiGetFullPathName

src/common/WObjects.cpp:196–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196int apiGetFullPathName(LPCWSTR lpFileName, CEStr& rsPath)
197{
198 if (!lpFileName || !*lpFileName)
199 {
200 _ASSERTE(lpFileName != nullptr);
201 return 0;
202 }
203
204 int iFoundLen = 0;
205 wchar_t* pszFilePart = nullptr;
206 // ReSharper disable once CppInitializedValueIsAlwaysRewritten
207 wchar_t* pszBuffer = nullptr;
208 wchar_t szFind[MAX_PATH+1] = L"";
209
210 DWORD nLen = GetFullPathName(lpFileName, countof(szFind), szFind, &pszFilePart);
211 if (nLen)
212 {
213 if (nLen < countof(szFind))
214 {
215 rsPath.Set(szFind);
216 iFoundLen = static_cast<int>(rsPath.GetLen());
217 }
218 else
219 {
220 // Too long path, allocate more space
221 pszBuffer = static_cast<wchar_t*>(malloc((++nLen)*sizeof(*pszBuffer)));
222 if (pszBuffer)
223 {
224 const DWORD nLen2 = GetFullPathName(lpFileName, nLen, pszBuffer, &pszFilePart);
225 if (nLen2 && (nLen2 < nLen))
226 {
227 rsPath.Set(pszBuffer);
228 iFoundLen = static_cast<int>(rsPath.GetLen());
229 }
230 free(pszBuffer);
231 }
232 }
233 }
234
235 return (iFoundLen > 0) ? iFoundLen : 0;
236}
237
238bool FileSearchInDir(LPCWSTR asFilePath, CEStr& rsFound)
239{

Callers 5

_CreateShellLinkFunction · 0.85
SetConfigFileMethod · 0.85
UpdateGuiInfoMappingMethod · 0.85
PrepareTabMethod · 0.85
GetFullPathNameExFunction · 0.85

Calls 2

GetLenMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected