** Returns the *path* portion of the filename fn. Memory is allocated using malloc. */
| 619 | ** Returns the *path* portion of the filename fn. Memory is allocated using malloc. |
| 620 | */ |
| 621 | char *msGetPath(char *fn) |
| 622 | { |
| 623 | char *str; |
| 624 | int i, length; |
| 625 | |
| 626 | length = strlen(fn); |
| 627 | if((str = msStrdup(fn)) == NULL) |
| 628 | return(NULL); |
| 629 | |
| 630 | for(i=length-1; i>=0; i--) { /* step backwards through the string */ |
| 631 | if((str[i] == '/') || (str[i] == '\\')) { |
| 632 | str[i+1] = '\0'; |
| 633 | break; |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | if(strcmp(str, fn) == 0) |
| 638 | { |
| 639 | msFree(str); |
| 640 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 641 | str = msStrdup(".\\"); |
| 642 | #else |
| 643 | str= msStrdup("./"); |
| 644 | #endif |
| 645 | } |
| 646 | |
| 647 | return(str); |
| 648 | } |
| 649 | |
| 650 | /* |
| 651 | ** Returns a *path* built from abs_path and path. |
no test coverage detected