MCPcopy Create free account
hub / github.com/boostorg/build / glob_recursive

Function glob_recursive

v2/engine/builtins.c:791–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

789
790
791LIST * glob_recursive( char const * pattern )
792{
793 LIST * result = L0;
794
795 /* Check if there's metacharacters in pattern */
796 if ( !has_wildcards( pattern ) )
797 {
798 /* No metacharacters. Check if the path exists. */
799 OBJECT * const p = object_new( pattern );
800 result = append_if_exists( result, p );
801 object_free( p );
802 }
803 else
804 {
805 /* Have metacharacters in the pattern. Split into dir/name. */
806 PATHNAME path[ 1 ];
807 path_parse( pattern, path );
808
809 if ( path->f_dir.ptr )
810 {
811 LIST * dirs = L0;
812 string dirname[ 1 ];
813 string basename[ 1 ];
814 string_new( dirname );
815 string_new( basename );
816
817 string_append_range( dirname, path->f_dir.ptr,
818 path->f_dir.ptr + path->f_dir.len );
819
820 path->f_grist.ptr = 0;
821 path->f_grist.len = 0;
822 path->f_dir.ptr = 0;
823 path->f_dir.len = 0;
824 path_build( path, basename );
825
826 dirs = has_wildcards( dirname->value )
827 ? glob_recursive( dirname->value )
828 : list_push_back( dirs, object_new( dirname->value ) );
829
830 if ( has_wildcards( basename->value ) )
831 {
832 OBJECT * const b = object_new( basename->value );
833 LISTITER iter = list_begin( dirs );
834 LISTITER const end = list_end( dirs );
835 for ( ; iter != end; iter = list_next( iter ) )
836 result = list_append( result, glob1( list_item( iter ), b )
837 );
838 object_free( b );
839 }
840 else
841 {
842 LISTITER iter = list_begin( dirs );
843 LISTITER const end = list_end( dirs );
844 string file_string[ 1 ];
845 string_new( file_string );
846
847 /* No wildcard in basename. */
848 for ( ; iter != end; iter = list_next( iter ) )

Callers 1

builtin_glob_recursiveFunction · 0.85

Calls 15

has_wildcardsFunction · 0.85
object_newFunction · 0.85
append_if_existsFunction · 0.85
object_freeFunction · 0.85
path_parseFunction · 0.85
string_newFunction · 0.85
string_append_rangeFunction · 0.85
path_buildFunction · 0.85
list_push_backFunction · 0.85
list_beginFunction · 0.85
list_endFunction · 0.85
list_appendFunction · 0.85

Tested by

no test coverage detected