this code was taken from WINE (LGPL) http://google.com/codesearch?hl=en&q=+lang:c+splitpath+show:CPvw9Z-euls:_RSotQzmLeU:KGzljMEYFbY&sa=N&cd=9&ct=rc&cs_p=http://gentoo.osuosl.org/distfiles/Wine-20050524.tar.gz&cs_f=wine-20050524/programs/winefile/splitpath.c
| 384 | //this code was taken from WINE (LGPL) |
| 385 | //http://google.com/codesearch?hl=en&q=+lang:c+splitpath+show:CPvw9Z-euls:_RSotQzmLeU:KGzljMEYFbY&sa=N&cd=9&ct=rc&cs_p=http://gentoo.osuosl.org/distfiles/Wine-20050524.tar.gz&cs_f=wine-20050524/programs/winefile/splitpath.c |
| 386 | void splitpath(const char* path, char* drv, char* dir, char* name, char* ext) |
| 387 | { |
| 388 | const char* end; /* end of processed string */ |
| 389 | const char* p; /* search pointer */ |
| 390 | const char* s; /* copy pointer */ |
| 391 | |
| 392 | /* extract drive name */ |
| 393 | if (path[0] && path[1]==':') { |
| 394 | if (drv) { |
| 395 | *drv++ = *path++; |
| 396 | *drv++ = *path++; |
| 397 | *drv = '\0'; |
| 398 | } else path+=2; |
| 399 | } else if (drv) |
| 400 | *drv = '\0'; |
| 401 | |
| 402 | /* search for end of string or stream separator */ |
| 403 | for(end=path; *end && *end!=':'; ) |
| 404 | end++; |
| 405 | |
| 406 | /* search for begin of file extension */ |
| 407 | for(p=end; p>path && *--p!='\\' && *p!='/'; ) |
| 408 | if (*p == '.') { |
| 409 | end = p; |
| 410 | break; |
| 411 | } |
| 412 | |
| 413 | if (ext) |
| 414 | for(s=end; (*ext=*s++); ) |
| 415 | ext++; |
| 416 | else |
| 417 | for(s=end; *s++; ) {} |
| 418 | |
| 419 | /* search for end of directory name */ |
| 420 | for(p=end; p>path; ) |
| 421 | if (*--p=='\\' || *p=='/') { |
| 422 | p++; |
| 423 | break; |
| 424 | } |
| 425 | |
| 426 | if (name) { |
| 427 | for(s=p; s<end; ) |
| 428 | *name++ = *s++; |
| 429 | |
| 430 | *name = '\0'; |
| 431 | } else |
| 432 | for(s=p; s<end; ) |
| 433 | s++; |
| 434 | |
| 435 | if (dir) { |
| 436 | for(s=path; s<p; ) |
| 437 | *dir++ = *s++; |
| 438 | |
| 439 | *dir = '\0'; |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | //mbg 5/12/08 |
no outgoing calls
no test coverage detected