| 362 | return src; |
| 363 | } |
| 364 | inline std::string path_base(std::string p) { |
| 365 | // "/usr/local/myfile.dat" -> "/usr/local" |
| 366 | // "foo/bar" -> "foo" |
| 367 | // "foo/bar/" -> "foo/bar" |
| 368 | #if defined _WIN32 || defined _WIN64 |
| 369 | char sep = '\\'; |
| 370 | #else |
| 371 | char sep = '/'; |
| 372 | #endif |
| 373 | size_t i = p.find_last_of(sep); |
| 374 | if (i != std::string::npos) { |
| 375 | return p.substr(0, i); |
| 376 | } else { |
| 377 | return ""; |
| 378 | } |
| 379 | } |
| 380 | inline std::string path_join(std::string p1, std::string p2) { |
| 381 | #ifdef _WIN32 |
| 382 | char sep = '\\'; |