Difference between revisions of "Truxton file export set option"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This gives you the ability to specify the output format to export from Truxton. =Syntax= <source lang="C"> void truxton_file_export_set_option(uint64_t export_handle, uint64_...")
 
 
(8 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
=Syntax=
 
=Syntax=
 
<source lang="C">
 
<source lang="C">
void truxton_file_export_set_option(uint64_t export_handle, uint64_t option, char const * value);
+
void truxton_file_export_set_option( uint64_t export_handle, uint64_t option, char const * value );
 
</source>
 
</source>
  
Line 21: Line 21:
 
==<code>TRUXTON_EXPORT_FILE_OPTION_NAME_FORMAT</code>==
 
==<code>TRUXTON_EXPORT_FILE_OPTION_NAME_FORMAT</code>==
 
The format of the names of files to export.
 
The format of the names of files to export.
 +
If you don't set this, the original name of the file will be used to export.
 +
However, you can specify a format string.
 +
 +
{| class="wikitable"
 +
! Field
 +
! Meaning
 +
|-
 +
| <code>{ext}</code>
 +
| The filename extension most commonly associated with this type of file.
 +
|-
 +
| <code>{hash}</code>
 +
| The MD5 hash of the file's contents.
 +
|-
 +
| <code>{name}</code>
 +
| The original name of the file.
 +
|}
 +
 +
'''NOTE''' If <code>{ext}</code> is used and the file type has no extension registered in the <code>[FileType]</code> table, the integer value of the file type will be used instead.
  
 
==<code>TRUXTON_EXPORT_FILE_OPTION_FOLDER</code>==
 
==<code>TRUXTON_EXPORT_FILE_OPTION_FOLDER</code>==
Line 29: Line 47:
 
This is an optional parameter.
 
This is an optional parameter.
 
If you don't set this, files will be written to the destination folder.
 
If you don't set this, files will be written to the destination folder.
 +
 +
==<code>TRUXTON_EXPORT_FILE_OPTION_UNIQUE</code>==
 +
If you set the value to "1" then only unique file contents will be exported.
  
 
=Sample=
 
=Sample=
<source lang="C" highlight="38,41,44">
+
<source lang="C" highlight="38,41,44,47">
 
#include "TruxtonCAPI.h"
 
#include "TruxtonCAPI.h"
 
#pragma comment(lib, "TruxtonCAPI.lib")
 
#pragma comment(lib, "TruxtonCAPI.lib")
Line 39: Line 60:
 
#pragma hdrstop
 
#pragma hdrstop
  
int main()
+
void main( void )
 
{
 
{
 
     char temporary_string[256];
 
     char temporary_string[256];
Line 47: Line 68:
 
     uint64_t truxton = truxton_create();
 
     uint64_t truxton = truxton_create();
  
     uint64_t export_handle = truxton_file_export_create(truxton);
+
     uint64_t export_handle = truxton_file_export_create( truxton );
  
 
     // We want a variety of file types
 
     // We want a variety of file types
     sprintf_s(temporary_string, sizeof(temporary_string), "%d, %d, %d", Type_JPEGWithExif, Type_JPEG, Type_GIF);
+
     sprintf_s( temporary_string, sizeof(temporary_string), "%d, %d, %d", Type_JPEGWithExif, Type_JPEG, Type_GIF );
     truxton_file_export_add_criteria(export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_TYPE, temp_string);
+
     truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_TYPE, temp_string );
  
 
     // We only want files where the MD5 hash starts with "e4"
 
     // We only want files where the MD5 hash starts with "e4"
     truxton_file_export_add_criteria(export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_HASH, "e4");
+
     truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_HASH, "e4" );
  
 
     // We want a file that is at least 4MB long
 
     // We want a file that is at least 4MB long
     truxton_file_export_add_criteria(export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_SIZE_MINIMUM, "4194304");
+
     truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_SIZE_MINIMUM, "4194304" );
  
 
     // We want a file that is no larger than 5MB
 
     // We want a file that is no larger than 5MB
     truxton_file_export_add_criteria(export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_SIZE_MAXIMUM, "5242880");
+
     truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_SIZE_MAXIMUM, "5242880" );
  
 
     // Limit the output to a single file
 
     // Limit the output to a single file
     truxton_file_export_add_criteria(export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_LIMIT, "1");
+
     truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_LIMIT, "1" );
  
     truxton_file_export_where_clause(export_handle, temporary_string, sizeof(temporary_string));
+
     truxton_file_export_where_clause( export_handle, temporary_string, sizeof(temporary_string) );
     printf( "Will use the following WHERE clause to select files: %s\n", temporary_string);
+
     printf( "Will use the following WHERE clause to select files: %s\n", temporary_string );
  
 
     // Rename the file being exported to include the hash before the original name
 
     // Rename the file being exported to include the hash before the original name
     truxton_file_export_set_option(export_handle, TRUXTON_EXPORT_FILE_OPTION_NAME_FORMAT, "{hash}_{name}");
+
     truxton_file_export_set_option( export_handle, TRUXTON_EXPORT_FILE_OPTION_NAME_FORMAT, "{hash}_{name}" );
  
 
     // The files should be output to a particular folder
 
     // The files should be output to a particular folder
     truxton_file_export_set_option(export_handle, TRUXTON_EXPORT_FILE_OPTION_FOLDER, "C:\\temp");
+
     truxton_file_export_set_option( export_handle, TRUXTON_EXPORT_FILE_OPTION_FOLDER, "C:\\temp" );
  
 
     // We want them output to a TAR file in that particular folder
 
     // We want them output to a TAR file in that particular folder
     truxton_file_export_set_option(export_handle, TRUXTON_EXPORT_FILE_OPTION_TAR, "JPGWithExif.tar");
+
     truxton_file_export_set_option( export_handle, TRUXTON_EXPORT_FILE_OPTION_TAR, "JPGWithExif.tar" );
 +
 
 +
    // We do not want duplicate file contents
 +
    truxton_file_export_set_option( export_handle, TRUXTON_EXPORT_FILE_OPTION_UNIQUE, "1" );
  
 
     // Go find the files and output them to C:\temp\JPGWithExif.tar
 
     // Go find the files and output them to C:\temp\JPGWithExif.tar
     truxton_file_export_execute(export_handle);
+
     truxton_file_export_execute( export_handle );
  
 
     // Clean up
 
     // Clean up
     truxton_file_export_destroy(export_handle);
+
     truxton_file_export_destroy( export_handle );
     truxton_destroy(truxton);
+
     truxton_destroy( truxton );
 
     truxton_stop();
 
     truxton_stop();
 
}
 
}
 
</source>
 
</source>

Latest revision as of 10:57, 3 February 2024

This gives you the ability to specify the output format to export from Truxton.

Syntax

void truxton_file_export_set_option( uint64_t export_handle, uint64_t option, char const * value );

Parameters

export_handle

The handle to an export instance created by the truxton_file_export_create() call.

option

Which option to set.

value

The string representation of the option.

Options

The following are the possible options to set.

TRUXTON_EXPORT_FILE_OPTION_NAME_FORMAT

The format of the names of files to export. If you don't set this, the original name of the file will be used to export. However, you can specify a format string.

Field Meaning
{ext} The filename extension most commonly associated with this type of file.
{hash} The MD5 hash of the file's contents.
{name} The original name of the file.

NOTE If {ext} is used and the file type has no extension registered in the [FileType] table, the integer value of the file type will be used instead.

TRUXTON_EXPORT_FILE_OPTION_FOLDER

The folder where exported files should be written.

TRUXTON_EXPORT_FILE_OPTION_TAR

The name of the tar file to write to. This is an optional parameter. If you don't set this, files will be written to the destination folder.

TRUXTON_EXPORT_FILE_OPTION_UNIQUE

If you set the value to "1" then only unique file contents will be exported.

Sample

#include "TruxtonCAPI.h"
#pragma comment(lib, "TruxtonCAPI.lib")

#include "filetypes.h"
#include <stdlib.h>
#pragma hdrstop

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

    truxton_start();

    uint64_t truxton = truxton_create();

    uint64_t export_handle = truxton_file_export_create( truxton );

    // We want a variety of file types
    sprintf_s( temporary_string, sizeof(temporary_string), "%d, %d, %d", Type_JPEGWithExif, Type_JPEG, Type_GIF );
    truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_TYPE, temp_string );

    // We only want files where the MD5 hash starts with "e4"
    truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_HASH, "e4" );

    // We want a file that is at least 4MB long
    truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_SIZE_MINIMUM, "4194304" );

    // We want a file that is no larger than 5MB
    truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_SIZE_MAXIMUM, "5242880" );

    // Limit the output to a single file
    truxton_file_export_add_criteria( export_handle, TRUXTON_EXPORT_FILE_QUERY_FIELD_LIMIT, "1" );

    truxton_file_export_where_clause( export_handle, temporary_string, sizeof(temporary_string) );
    printf( "Will use the following WHERE clause to select files: %s\n", temporary_string );

    // Rename the file being exported to include the hash before the original name
    truxton_file_export_set_option( export_handle, TRUXTON_EXPORT_FILE_OPTION_NAME_FORMAT, "{hash}_{name}" );

    // The files should be output to a particular folder
    truxton_file_export_set_option( export_handle, TRUXTON_EXPORT_FILE_OPTION_FOLDER, "C:\\temp" );

    // We want them output to a TAR file in that particular folder
    truxton_file_export_set_option( export_handle, TRUXTON_EXPORT_FILE_OPTION_TAR, "JPGWithExif.tar" );

    // We do not want duplicate file contents
    truxton_file_export_set_option( export_handle, TRUXTON_EXPORT_FILE_OPTION_UNIQUE, "1" );

    // Go find the files and output them to C:\temp\JPGWithExif.tar
    truxton_file_export_execute( export_handle );

    // Clean up
    truxton_file_export_destroy( export_handle );
    truxton_destroy( truxton );
    truxton_stop();
}