A file scope helper function to concat path and file into a full path
| 125 | // A file scope helper function to concat path and file into |
| 126 | // a full path |
| 127 | static char* CreateFullPath(const std::string& path, const char* file) |
| 128 | { |
| 129 | size_t lenpath = path.size(); |
| 130 | char* ret = new char[lenpath + strlen(file) + 2]; |
| 131 | #ifdef _WIN32 |
| 132 | const char sep = '\\'; |
| 133 | #else |
| 134 | constexpr char sep = '/'; |
| 135 | #endif |
| 136 | // make sure the end of path is a separator |
| 137 | strcpy(ret, path.c_str()); |
| 138 | if (ret[lenpath - 1] != sep) |
| 139 | { |
| 140 | ret[lenpath] = sep; |
| 141 | ret[lenpath + 1] = 0; |
| 142 | } |
| 143 | strcat(ret, file); |
| 144 | return ret; |
| 145 | } |
| 146 | |
| 147 | // A file scope typedef to make the cast code to the load |
| 148 | // function cleaner to read. |
no test coverage detected