MCPcopy Create free account
hub / github.com/avast/retdec / stripDirs

Function stripDirs

src/utils/string.cpp:799–805  ·  view source on GitHub ↗

* @brief Strips all directories from the given path. * * For example, stripDirs("/home/user/test.c") returns @c "test.c". * * TODO Implement the following functionality: * - paths on MS Windows ('\' vs '/') * - allow backslashed '/' in file names */

Source from the content-addressed store, hash-verified

797* - allow backslashed '/' in file names
798*/
799std::string stripDirs(const std::string &path) {
800 std::size_t endPos = path.find_last_of('/');
801 if (endPos + 1 < path.length()) {
802 return path.substr(endPos + 1);
803 }
804 return path;
805}
806
807/**
808* @brief Replaces all occurrences of @a from in @a str with @a to and returns

Callers 2

getIdentifierMethod · 0.85
TEST_FFunction · 0.85

Calls 1

lengthMethod · 0.80

Tested by 1

TEST_FFunction · 0.68