A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Does this function memory leak?
D.D.K-2637
966
Reputation points
Hi,
I'm using the following function to get the filename (with extension).
However when putting it in a loop (in a thread) my program crashed.
How should I fix this code?
namespace fs = boost::filesystem;
std::wstring FileName(const std::wstring& filePath, bool withExtension=1)
{
filesys::path pathObj(filePath);
if (withExtension == false)
{
if (pathObj.has_stem())
{
return pathObj.stem().wstring();
}
return {};
}
else
{
return pathObj.filename().wstring(); <--crash
}
}
=FileName(L"!Person-Haley::Bittet");
Developer technologies | C++
Developer technologies | C++
Sign in to answer