static void file_archivescan_impl( OBJECT * path, archive_scanback func, void * closure ) { file_archive_info_t * const archive = file_archive_query( path ); if ( !archive || !archive->file->is_file ) return; /* Lazy collect the archive content information. */ if ( filelist_empty( archive->members ) ) { if ( DEBUG_BINDSCAN ) printf( "scan archive %s\n", object_str( archive->file->name ) ); if ( file_collect_archive_content_( archive ) < 0 ) return; } /* OS specific part of the file_archivescan operation. */ file_archivescan_( archive, func, closure ); /* Report the collected archive content. */ { FILELISTITER iter = filelist_begin( archive->members ); FILELISTITER const end = filelist_end( archive->members ); char buf[ MAXJPATH ]; for ( ; iter != end ; iter = filelist_next( iter ) ) { file_info_t * member_file = filelist_item( iter ); LIST * symbols = member_file->files; /* Construct member path: 'archive-path(member-name)' */ sprintf( buf, "%s(%s)", object_str( archive->file->name ), object_str( member_file->name ) ); { OBJECT * const member = object_new( buf ); (*func)( closure, member, symbols, 1, &member_file->time ); object_free( member ); } } } }
/* * file_archscan() - scan an archive for files */ void file_archscan( char const * arch, scanback func, void * closure ) { OBJECT * path = object_new( arch ); file_archive_info_t * archive = file_archive_query( path ); object_free( path ); if ( filelist_empty( archive->members ) ) { if ( file_collect_archive_content_( archive ) < 0 ) return; } /* Report the collected archive content. */ { FILELISTITER iter = filelist_begin( archive->members ); FILELISTITER const end = filelist_end( archive->members ); char buf[ MAXJPATH ]; for ( ; iter != end ; iter = filelist_next( iter ) ) { file_info_t * member_file = filelist_item( iter ); LIST * symbols = member_file->files; /* Construct member path: 'archive-path(member-name)' */ sprintf( buf, "%s(%s)", object_str( archive->file->name ), object_str( member_file->name ) ); { OBJECT * const member = object_new( buf ); (*func)( closure, member, 1 /* time valid */, &member_file->time ); object_free( member ); } } } }