MCPcopy Create free account
hub / github.com/PixarAnimationStudios/OpenUSD / TfGetBaseName

Function TfGetBaseName

pxr/base/tf/stringUtils.cpp:296–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296string
297TfGetBaseName(const string& fileName)
298{
299 if (fileName.empty())
300 return fileName;
301#if defined(ARCH_OS_WINDOWS)
302 const string::size_type i = fileName.find_last_of("\\/");
303#else
304 const string::size_type i = fileName.rfind("/");
305#endif
306 if (i == fileName.size() - 1) // ends in directory delimiter
307 return TfGetBaseName(fileName.substr(0, i));
308#if defined(ARCH_OS_WINDOWS)
309 const std::wstring wfileName{ ArchWindowsUtf8ToUtf16(fileName) };
310 LPWSTR result = PathFindFileNameW(wfileName.c_str());
311
312 // If PathFindFilename returns the same string back, that means it didn't
313 // do anything. That could mean that the patch has no basename, in which
314 // case we want to return the empty string, or it could mean that the
315 // fileName was already basename, in which case we want to return the
316 // string back.
317 if (result == wfileName.c_str()) {
318 const bool hasDriveLetter = fileName.find(":") != string::npos;
319 const bool hasPathSeparator = i != string::npos;
320 if (hasDriveLetter || hasPathSeparator) {
321 return std::string();
322 }
323 }
324 return ArchWindowsUtf16ToUtf8(result);
325
326#else
327 if (i == string::npos) // no / in name
328 return fileName;
329 else
330 return fileName.substr(i+1);
331#endif
332}
333
334string
335TfGetPathName(const string& fileName)

Callers 15

mainFunction · 0.85
_ProcessInputMethod · 0.85
_ParseGLSLSectionLineMethod · 0.85
_ComposeConfigurationMethod · 0.85
RemapMethod · 0.85
BuildMethod · 0.85
_ProcessAssetPathMethod · 0.85
_AddLayerToPackageMethod · 0.85
_GetTemplatedClipsMethod · 0.85

Calls 8

ArchWindowsUtf8ToUtf16Function · 0.85
ArchWindowsUtf16ToUtf8Function · 0.85
rfindMethod · 0.80
stringClass · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
findMethod · 0.45

Tested by 7

_GenerateDynamicLayerMethod · 0.68
mainFunction · 0.68
TestStringsFunction · 0.68
ParseErrorFunction · 0.68
UsageFunction · 0.68