Difference between revisions of "Truxton file get truxton"

From truxwiki.com
Jump to navigation Jump to search
 
Line 2: Line 2:
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
 
uint64_t truxton_file_get_truxton( uint64_t file_handle );
 
uint64_t truxton_file_get_truxton( uint64_t file_handle );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
Line 19: Line 19:
  
 
=Sample=
 
=Sample=
 
+
<source lang="C" highlight="10">
<syntaxhighlight lang="C" highlight="10">
+
void print_it( uint64_t truxton )
void print_it(uint64_t truxton)
 
 
{
 
{
   uint64_t file = truxton_file_open_md5(truxton, "9ec8fb6095c35eff2b236863b7caaf10");
+
   uint64_t file = truxton_file_open_md5( truxton, "9ec8fb6095c35eff2b236863b7caaf10" );
  
 
   if ( file != 0 )
 
   if ( file != 0 )
Line 40: Line 39:
 
   truxton_file_free( file );
 
   truxton_file_free( file );
 
}
 
}
</syntaxhighlight>
+
</source>

Latest revision as of 17:28, 10 February 2021

This retrieves the handle to the Truxton instance handling this file object.

Syntax

uint64_t truxton_file_get_truxton( uint64_t file_handle );

Parameters

file_handle

The handle created by the truxton_file_open_id or truxton_file_open_md5 call.

Return value

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

Remarks

This allows you to call any API that requires a handle to the Truxton object. Many times, in code, you are given one type of thing but need another. Should you find yourself in a situation where you were given file handle and you need to do something at the Truxton level, you can get the handle you need.

Sample

void print_it( uint64_t truxton )
{
   uint64_t file = truxton_file_open_md5( truxton, "9ec8fb6095c35eff2b236863b7caaf10" );

   if ( file != 0 )
   {
      return;
   }

   uint64_t truxton = truxton_file_get_truxton( file );

   char version_string[ 40 ];

   truxton_get_version( truxton , version_string, sizeof( version_string ) );

   printf( "Version: %s\n", version_string );

   truxton_file_free( file );
}