| 38 | namespace file { |
| 39 | |
| 40 | bool 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 | |
| 62 | std::string getFullPath(const std::string& path) { |
| 63 | #ifdef WIN32 |
no test coverage detected