| 296 | //========================================================================== |
| 297 | |
| 298 | FString ExtractFileBase (const char *path, bool include_extension, bool forcebackslash) |
| 299 | { |
| 300 | const char *src, *dot; |
| 301 | |
| 302 | src = path + strlen(path) - 1; |
| 303 | |
| 304 | if (src >= path) |
| 305 | { |
| 306 | // back up until a / or the start |
| 307 | while (src != path && !IsSeperator(*(src-1), forcebackslash)) |
| 308 | src--; |
| 309 | |
| 310 | // Check for files with drive specification but no path |
| 311 | #if defined(_WIN32) |
| 312 | if (src == path && src[0] != 0) |
| 313 | { |
| 314 | if (src[1] == ':') |
| 315 | src += 2; |
| 316 | } |
| 317 | #endif |
| 318 | |
| 319 | if (!include_extension && (dot = strrchr(src, '.'))) |
| 320 | { |
| 321 | return FString(src, dot - src); |
| 322 | } |
| 323 | else |
| 324 | { |
| 325 | return FString(src); |
| 326 | } |
| 327 | } |
| 328 | return FString(); |
| 329 | } |
| 330 | |
| 331 | //========================================================================== |
| 332 | // |
no test coverage detected