| | 715 | Returns a STRING that contains the specified path, separated by colons (:). |
| | 716 | |
| | 717 | The C<enum_runtime_ft type> is one or more of the types defined in |
| | 718 | F<include/parrot/library.h>. |
| | 719 | |
| | 720 | =cut |
| | 721 | |
| | 722 | */ |
| | 723 | |
| | 724 | PARROT_EXPORT |
| | 725 | PARROT_WARN_UNUSED_RESULT |
| | 726 | PARROT_CAN_RETURN_NULL |
| | 727 | STRING* |
| | 728 | Parrot_path_str(PARROT_INTERP, enum_runtime_ft type) |
| | 729 | { |
| | 730 | ASSERT_ARGS(Parrot_path_str) |
| | 731 | STRING *prefix; |
| | 732 | STRING *full_path; |
| | 733 | PMC *paths; |
| | 734 | INTVAL i, n; |
| | 735 | |
| | 736 | /* TODO: Get the real separator, not this hacked-together stuff */ |
| | 737 | #ifdef WIN32 |
| | 738 | STRING * const envpathsep = CONST_STRING(interp, ";"); |
| | 739 | #else |
| | 740 | STRING * const envpathsep = CONST_STRING(interp, ":"); |
| | 741 | #endif |
| | 742 | |
| | 743 | if (type & PARROT_RUNTIME_FT_DYNEXT) |
| | 744 | paths = get_search_paths(interp, PARROT_LIB_PATH_DYNEXT); |
| | 745 | else if (type & (PARROT_RUNTIME_FT_PBC | PARROT_RUNTIME_FT_SOURCE)) |
| | 746 | paths = get_search_paths(interp, PARROT_LIB_PATH_LIBRARY); |
| | 747 | else |
| | 748 | paths = get_search_paths(interp, PARROT_LIB_PATH_INCLUDE); |
| | 749 | |
| | 750 | prefix = Parrot_get_runtime_path(interp); |
| | 751 | n = VTABLE_elements(interp, paths); |
| | 752 | |
| | 753 | for (i = 0; i < n; ++i) { |
| | 754 | STRING * const path = VTABLE_get_string_keyed_int(interp, paths, i); |
| | 755 | STRING *found_name; |
| | 756 | |
| | 757 | if ( 0 == i ) { |
| | 758 | full_path = Parrot_str_copy(interp, path); |
| | 759 | } else { |
| | 760 | if(path) { |
| | 761 | full_path = Parrot_str_append(interp, full_path, envpathsep); |
| | 762 | full_path = Parrot_str_append(interp, full_path, path); |
| | 763 | } |
| | 764 | } |
| | 765 | } |
| | 766 | |
| | 767 | return full_path; |
| | 768 | } |
| | 769 | |
| | 770 | /* |
| | 771 | |