Jams two paths together with the right kind of slash */
| 235 | |
| 236 | /** Jams two paths together with the right kind of slash */ |
| 237 | std::string Path_Join( const std::string & first, const std::string & second, char slash ) |
| 238 | { |
| 239 | if( slash == 0 ) |
| 240 | slash = Path_GetSlash(); |
| 241 | |
| 242 | // only insert a slash if we don't already have one |
| 243 | std::string::size_type nLen = first.length(); |
| 244 | if( !nLen ) |
| 245 | return second; |
| 246 | #if defined(_WIN32) |
| 247 | if( first.back() == '\\' || first.back() == '/' ) |
| 248 | nLen--; |
| 249 | #else |
| 250 | char last_char = first[first.length()-1]; |
| 251 | if (last_char == '\\' || last_char == '/') |
| 252 | nLen--; |
| 253 | #endif |
| 254 | |
| 255 | return first.substr( 0, nLen ) + std::string( 1, slash ) + second; |
| 256 | } |
| 257 | |
| 258 | |
| 259 | std::string Path_Join( const std::string & first, const std::string & second, const std::string & third, char slash ) |
no test coverage detected