511 | | return !strncmp(dirPath.Path(), entryPath.Path(), strlen(dirPath.Path())); |
| 512 | // we need to compare path components individually |
| 513 | // for correctness |
| 514 | const char *dirStr = dirPath.Path(); |
| 515 | const char *entryStr = entryPath.Path(); |
| 516 | if (dirStr[0] == '/') |
| 517 | ++dirStr; |
| 518 | if (entryStr[0] == '/') |
| 519 | ++entryStr; |
| 520 | while (dirStr[0] != '\0') { |
| 521 | const char *slashPos = strchr(dirStr, '/'); |
| 522 | const char *entryPos = strchr(entryStr, '/'); |
| 523 | if (slashPos == NULL) { |
| 524 | if (entryPos == NULL) |
| 525 | return strcmp(dirStr, entryStr) == 0; |
| 526 | else |
| 527 | return strncmp(dirStr, entryStr, entryPos - entryStr) == 0; |
| 528 | } else { |
| 529 | if (entryPos == NULL) |
| 530 | return false; |
| 531 | if (entryPos - entryStr != slashPos - dirStr) |
| 532 | return false; |
| 533 | if (strncmp(dirStr, entryStr, slashPos - dirStr) != 0) |
| 534 | return false; |
| 535 | } |
| 536 | |
| 537 | dirStr = slashPos + 1; |
| 538 | entryStr = entryPos + 1; |
| 539 | } |
| 540 | |
| 541 | return false; |