| | 771 | =item C<STRING* Parrot_path_str> |
| | 772 | |
| | 773 | Returns a STRING that contains the specified path, separated by colons (:). |
| | 774 | |
| | 775 | The C<enum_runtime_ft type> is one or more of the types defined in |
| | 776 | F<include/parrot/library.h>. |
| | 777 | |
| | 778 | =cut |
| | 779 | |
| | 780 | */ |
| | 781 | |
| | 782 | PARROT_EXPORT |
| | 783 | PARROT_WARN_UNUSED_RESULT |
| | 784 | PARROT_CAN_RETURN_NULL |
| | 785 | STRING* |
| | 786 | Parrot_path_str(PARROT_INTERP, enum_runtime_ft type) |
| | 787 | { |
| | 788 | ASSERT_ARGS(Parrot_path_str) |
| | 789 | STRING *prefix; |
| | 790 | STRING *full_path; |
| | 791 | PMC *paths; |
| | 792 | INTVAL i, n; |
| | 793 | |
| | 794 | /* TODO: Get the real separator, not this hacked-together stuff */ |
| | 795 | #ifdef WIN32 |
| | 796 | STRING * const envpathsep = CONST_STRING(interp, ";"); |
| | 797 | #else |
| | 798 | STRING * const envpathsep = CONST_STRING(interp, ":"); |
| | 799 | #endif |
| | 800 | |
| | 801 | if (type & PARROT_RUNTIME_FT_DYNEXT) |
| | 802 | paths = get_search_paths(interp, PARROT_LIB_PATH_DYNEXT); |
| | 803 | else if (type & (PARROT_RUNTIME_FT_PBC | PARROT_RUNTIME_FT_SOURCE)) |
| | 804 | paths = get_search_paths(interp, PARROT_LIB_PATH_LIBRARY); |
| | 805 | else |
| | 806 | paths = get_search_paths(interp, PARROT_LIB_PATH_INCLUDE); |
| | 807 | |
| | 808 | prefix = Parrot_get_runtime_path(interp); |
| | 809 | n = VTABLE_elements(interp, paths); |
| | 810 | |
| | 811 | for (i = 0; i < n; ++i) { |
| | 812 | STRING * const path = VTABLE_get_string_keyed_int(interp, paths, i); |
| | 813 | STRING *found_name; |
| | 814 | |
| | 815 | if ( 0 == i ) { |
| | 816 | full_path = Parrot_str_copy(interp, path); |
| | 817 | } else { |
| | 818 | if(path) { |
| | 819 | full_path = Parrot_str_append(interp, full_path, envpathsep); |
| | 820 | full_path = Parrot_str_append(interp, full_path, path); |
| | 821 | } |
| | 822 | } |
| | 823 | } |
| | 824 | |
| | 825 | return full_path; |
| | 826 | } |
| | 827 | |
| | 828 | /* |
| | 829 | |