Truxton enumeration get current file

From truxwiki.com
Jump to navigation Jump to search

Creates an enumeration object.

Syntax

uint64_t truxton_enumeration_get_current_file( uint64_t enumerator );

Parameters

enumerator

This handle comes from calling truxton_enumeration_create().

Return value

A non-zero value on success, zero on failure.

Sample

void find_pilot_home_point( uint64_t truxton_handle, uint64_t investigation_handle )
{
    uint64_t location_type;

    char media_name[ 256 ];
    char file_name[ 256 ];
    char investigation_id[ 65 ];

    truxton_investigation_get_id( investigation_handle, investigation_id, sizeof( investigation_id ) );

    uint64_t enumerator = truxton_enumeration_create( truxton );

    // Now setup the enumeration to get the media in a particular investigation
    truxton_enumeration_set_scope( enumerator, Type_Investigation );
    truxton_enumeration_set_scope_id( enumerator, investigation_id );
    truxton_enumeration_set_target( enumerator, Type_Location );

    uint64_t location_handle = truxton_enumeration_get_next( enumerator );

    while( location_handle != 0 )
    {
        location_type = truxton_location_get_type( location_handle );

        if ( location_type == LOCATION_TYPE_PILOT_LOCATION )
        {
           uint64_t file_handle = truxton_enumeration_get_current_file( enumerator );
           uint64_t media_handle = truxton_enumeration_get_current_media( enumerator );

           truxton_media_get_name( media_handle, media_name, sizeof( media_name ) );
           printf( "Media: %s\n", media_name );

           truxton_file_get_name( file_handle, file_name, sizeof( file_name ) );
           printf( "Found Drone Pilot Location in: %s\n", file_name );
        }

        location_handle = truxton_enumeration_get_next( enumerator );
    }

    truxton_enumeration_destroy( enumerator );
}

void main( void )
{
    char investigation_name[256];

    truxton_start();

    uint64_t truxton = truxton_create();

    uint64_t enumerator = truxton_enumeration_create( truxton );

    truxton_enumeration_set_target( enumerator, Type_Investigation );

    uint64_t investigation_handle = truxton_enumeration_get_next( enumerator );

    while( investigation_handle != 0 )
    {
        truxton_investigation_get_name( investigation_handle, investigation_name, sizeof( investigation_name ) );

        printf( "Investigation: %s\n", investigation_name );

        find_pilot_home_point( truxton, investigation_handle );

        investigation_handle = truxton_enumeration_get_next( enumerator );
    }

    truxton_enumeration_destroy( enumerator );
    truxton_destroy( truxton );
    truxton_stop();
}