remove duplicates dir resp. those which do not exist
| 525 | |
| 526 | // remove duplicates dir resp. those which do not exist |
| 527 | static char* feCleanUpPath(char* path) |
| 528 | { |
| 529 | #ifdef RESOURCE_DEBUG |
| 530 | printf("feCleanUpPath: entering with: =%s=\n", path); |
| 531 | #endif |
| 532 | if (path == NULL) return path; |
| 533 | |
| 534 | int n_comps = 1, i, j; |
| 535 | char* opath = path; |
| 536 | char** path_comps; |
| 537 | |
| 538 | for (; *path != '\0'; path++) |
| 539 | { |
| 540 | if (*path == fePathSep) n_comps++; |
| 541 | else if (*path == ';') |
| 542 | { |
| 543 | *path = fePathSep; |
| 544 | n_comps++; |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | path_comps = (char**) malloc(n_comps*sizeof(char*)); |
| 549 | path_comps[0]=opath; |
| 550 | path=opath; |
| 551 | i = 1; |
| 552 | |
| 553 | if (i < n_comps) |
| 554 | { |
| 555 | while (1) |
| 556 | { |
| 557 | if (*path == fePathSep) |
| 558 | { |
| 559 | *path = '\0'; |
| 560 | path_comps[i] = path+1; |
| 561 | i++; |
| 562 | if (i == n_comps) break; |
| 563 | } |
| 564 | path++; |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | for (i=0; i<n_comps; i++) |
| 569 | path_comps[i] = feCleanUpFile(path_comps[i]); |
| 570 | #ifdef RESOURCE_DEBUG |
| 571 | printf("feCleanUpPath: after CleanUpName: "); |
| 572 | for (i=0; i<n_comps; i++) |
| 573 | printf("%s:", path_comps[i]); |
| 574 | printf("\n"); |
| 575 | #endif |
| 576 | |
| 577 | for (i=0; i<n_comps;) |
| 578 | { |
| 579 | #ifdef RESOURCE_DEBUG |
| 580 | if (access(path_comps[i], X_OK | R_OK)) |
| 581 | printf("feCleanUpPath: remove %d:%s -- can not access\n", i, path_comps[i]); |
| 582 | #endif |
| 583 | if ( ! access(path_comps[i], X_OK | R_OK)) |
| 584 | { |
no test coverage detected