Difference between revisions of "Truxton file length"
Jump to navigation
Jump to search
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
This tells you the size of the opened file in bytes. | This tells you the size of the opened file in bytes. | ||
=Syntax= | =Syntax= | ||
| − | < | + | <source lang="C"> |
int64_t truxton_file_length( uint64_t file_handle ); | int64_t truxton_file_length( uint64_t file_handle ); | ||
| − | </ | + | </source> |
=Parameters= | =Parameters= | ||
| Line 11: | Line 11: | ||
=Return value= | =Return value= | ||
The length of the file in bytes. | The length of the file in bytes. | ||
| + | If the file's contents were eliminated for any reason, the length will be zero because there are no contents to read. | ||
=Sample= | =Sample= | ||
| − | < | + | <source lang="C" highlight="12"> |
| − | int does_file_have_deep_philosophical_meaning(uint64_t truxton) | + | int does_file_have_deep_philosophical_meaning( uint64_t truxton ) |
{ | { | ||
| − | uint64_t file = truxton_file_open_id(truxton, "5ed3aeb7-3da4-5f5c-8c8f-af5200000000"); | + | uint64_t file = truxton_file_open_id( truxton, "5ed3aeb7-3da4-5f5c-8c8f-af5200000000" ); |
if ( file != 0 ) | if ( file != 0 ) | ||
{ | { | ||
| − | return(0); | + | return( 0 ); |
} | } | ||
| Line 27: | Line 28: | ||
if ( truxton_file_length( file ) > 42 ) | if ( truxton_file_length( file ) > 42 ) | ||
{ | { | ||
| − | truxton_file_seek(file, 42, 0 ); | + | truxton_file_seek( file, 42, 0 ); |
if ( truxton_file_tell( file ) == 42 ) | if ( truxton_file_tell( file ) == 42 ) | ||
| Line 35: | Line 36: | ||
} | } | ||
| − | truxton_file_free(file); | + | truxton_file_free( file ); |
return( return_value ); | return( return_value ); | ||
} | } | ||
| − | </ | + | </source> |
Latest revision as of 17:32, 10 February 2021
This tells you the size of the opened file in bytes.
Syntax
int64_t truxton_file_length( uint64_t file_handle );
Parameters
file_handle
The handle created by the truxton_file_open_id or truxton_file_open_md5 call.
Return value
The length of the file in bytes. If the file's contents were eliminated for any reason, the length will be zero because there are no contents to read.
Sample
int does_file_have_deep_philosophical_meaning( uint64_t truxton )
{
uint64_t file = truxton_file_open_id( truxton, "5ed3aeb7-3da4-5f5c-8c8f-af5200000000" );
if ( file != 0 )
{
return( 0 );
}
int return_value = 0;
if ( truxton_file_length( file ) > 42 )
{
truxton_file_seek( file, 42, 0 );
if ( truxton_file_tell( file ) == 42 )
{
return_value = 1;
}
}
truxton_file_free( file );
return( return_value );
}