LIST * builtin_glob( PARSE *parse, LOL *args, int *jmp ) { LIST *l = lol_get( args, 0 ); LIST *r = lol_get( args, 1 ); #ifdef OPT_SCAN_SUBDIR_NOTIFY_EXT LIST *prepend = lol_get( args, 2 ); #endif struct globbing globbing; globbing.results = L0; globbing.patterns = r; #ifdef OPT_SCAN_SUBDIR_NOTIFY_EXT globbing.prependdir = 1; if ( prepend ) { if ( strcmp( prepend->string, "1" ) == 0 || strcmp( prepend->string, "true" ) == 0 ) globbing.prependdir = 1; else globbing.prependdir = 0; } for( ; l; l = list_next( l ) ) { globbing.dirname = l->string; globbing.dirnamelen = strlen( l->string ); if ( globbing.dirname[ globbing.dirnamelen - 1 ] != '/' && globbing.dirname[ globbing.dirnamelen - 1 ] != '\\' ) globbing.dirnamelen++; file_dirscan( l->string, builtin_glob_back, &globbing ); } #else for( ; l; l = list_next( l ) ) file_dirscan( l->string, builtin_glob_back, &globbing ); #endif return globbing.results; }
void timestamp( char *target, time_t *time ) { PATHNAME f1, f2; BINDING binding, *b = &binding; string buf[1]; # ifdef DOWNSHIFT_PATHS string path; char *p; string_copy( &path, target ); p = path.value; do *p = tolower( *p ); while( *p++ ); target = path.value; # endif string_new( buf ); if( !bindhash ) bindhash = hashinit( sizeof( BINDING ), "bindings" ); /* Quick path - is it there? */ b->name = target; b->time = b->flags = 0; b->progress = BIND_INIT; if( hashenter( bindhash, (HASHDATA **)&b ) ) b->name = newstr( target ); /* never freed */ if( b->progress != BIND_INIT ) goto afterscanning; b->progress = BIND_NOENTRY; /* Not found - have to scan for it */ path_parse( target, &f1 ); /* Scan directory if not already done so */ { BINDING binding, *b = &binding; f2 = f1; f2.f_grist.len = 0; path_parent( &f2 ); path_build( &f2, buf, 0 ); b->name = buf->value; b->time = b->flags = 0; b->progress = BIND_INIT; if( hashenter( bindhash, (HASHDATA **)&b ) ) b->name = newstr( buf->value ); /* never freed */ if( !( b->flags & BIND_SCANNED ) ) { file_dirscan( buf->value, time_enter, bindhash ); b->flags |= BIND_SCANNED; } } /* Scan archive if not already done so */ if( f1.f_member.len ) { BINDING binding, *b = &binding; f2 = f1; f2.f_grist.len = 0; f2.f_member.len = 0; string_truncate( buf, 0 ); path_build( &f2, buf, 0 ); b->name = buf->value; b->time = b->flags = 0; b->progress = BIND_INIT; if( hashenter( bindhash, (HASHDATA **)&b ) ) b->name = newstr( buf->value ); /* never freed */ if( !( b->flags & BIND_SCANNED ) ) { file_archscan( buf->value, time_enter, bindhash ); b->flags |= BIND_SCANNED; } } afterscanning: if( b->progress == BIND_SPOTTED ) { if( file_time( b->name, &b->time ) < 0 ) b->progress = BIND_MISSING; else b->progress = BIND_FOUND; } *time = b->progress == BIND_FOUND ? b->time : 0; string_free( buf ); # ifdef DOWNSHIFT_PATHS string_free( &path ); #endif }