| 332 | } |
| 333 | |
| 334 | String File::path(const String& file) |
| 335 | { |
| 336 | size_t pos = file.find_last_of("\\/"); |
| 337 | // do NOT return an empty string, because this leads to issues when in generic code you do: |
| 338 | // String new_path = path("a.txt") + '/' + basename("a.txt"); |
| 339 | // , as this would lead to "/a.txt", i.e. create a wrong absolute path from a relative name |
| 340 | String no_path = "."; |
| 341 | return pos == string::npos ? no_path : file.substr(0, pos); |
| 342 | } |
| 343 | |
| 344 | bool File::readable(const String& file) |
| 345 | { |
no test coverage detected