MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / getFileNameAndPath

Function getFileNameAndPath

libminifi/src/utils/file/PathUtils.cpp:40–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38namespace file {
39
40bool getFileNameAndPath(const std::string &path, std::string &filePath, std::string &fileName) {
41 const std::size_t found = path.find_last_of(FileUtils::get_separator());
42 /**
43 * Don't make an assumption about about the path, return false for this case.
44 * Could make the assumption that the path is just the file name but with the function named
45 * getFileNameAndPath we expect both to be there ( a fully qualified path ).
46 *
47 */
48 if (found == std::string::npos || found == path.length() - 1) {
49 return false;
50 }
51 if (found == 0) {
52 filePath = ""; // don't assume that path is not empty
53 filePath += FileUtils::get_separator();
54 fileName = path.substr(found + 1);
55 return true;
56 }
57 filePath = path.substr(0, found);
58 fileName = path.substr(found + 1);
59 return true;
60}
61
62std::string getFullPath(const std::string& path) {
63#ifdef WIN32

Callers 6

mainFunction · 0.85
FileUtilsTests.cppFile · 0.85
TailFileTests.cppFile · 0.85
onScheduleMethod · 0.85
parseStateFileLineMethod · 0.85

Calls 2

lengthMethod · 0.80
get_separatorFunction · 0.50

Tested by

no test coverage detected