MCPcopy Create free account
hub / github.com/Singular/Singular / feCleanUpPath

Function feCleanUpPath

resources/feResource.cc:527–633  ·  view source on GitHub ↗

remove duplicates dir resp. those which do not exist

Source from the content-addressed store, hash-verified

525
526// remove duplicates dir resp. those which do not exist
527static 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 {

Callers 1

feCleanResourceValueFunction · 0.85

Calls 4

mallocFunction · 0.85
feCleanUpFileFunction · 0.85
mystrcpyFunction · 0.85
freeFunction · 0.85

Tested by

no test coverage detected