Difference between revisions of "Truxton child file create"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This create a child file object that you can populate with information before adding it to Truxton. =Syntax= <syntaxhighlight lang="C"> uint64_t truxton_child_file_create( ui...")
 
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
This create a child file object that you can populate with information before adding it to Truxton.
+
This creates a child file object that you can populate with information before adding it to Truxton.
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
uint64_t truxton_child_file_create( uint64_t trutxon_handle );
+
uint64_t truxton_child_file_create( uint64_t truxton_handle );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
 
==<code>truxton_handle</code>==
 
==<code>truxton_handle</code>==
 
+
The Truxton instance this child file will belong.
The handle created by the [[truxton_create]] call.
+
This handle comes from calling <code>[[truxton_create]]()</code>.
  
 
=Return value=
 
=Return value=
Line 15: Line 15:
  
 
=Sample=
 
=Sample=
 
+
<source lang="C" highlight="5">
<syntaxhighlight lang="C" highlight="5">
+
void add_folder( uint64_t truxton, uint64_t parent_file )
void add_folder(uint64_t truxton, uint64_t parent_file)
 
 
{
 
{
   truxton_start_adding_files(truxton);
+
   truxton_start_adding_files( truxton );
  
   uint64_t child = truxton_child_file_create(truxton);
+
   uint64_t child = truxton_child_file_create( truxton );
  
 
   char id[40];
 
   char id[40];
  
   truxton_file_get_id(parent_file, id, sizeof(id));
+
   truxton_file_get_id( parent_file, id, sizeof(id) );
   truxton_child_file_set_parent_id(child, id);
+
   truxton_child_file_set_parent_id( child, id );
   truxton_child_file_set_type(child, Type_Directory);
+
   truxton_child_file_set_type( child, Type_Directory );
   truxton_child_file_set_name(child, "Custom Exploits Folder");
+
   truxton_child_file_set_name( child, "Custom Exploits Folder" );
 
 
  FILETIME now;
 
 
 
  GetSystemTimeAsFileTime(&now);
 
 
 
  ULARGE_INTEGER ticks;
 
  
   ticks.LowPart = now.dwLowDateTime;
+
   uint64_t now = truxton_time_now();
  ticks.HighPart = now.dwHighDateTime;
 
  
   truxton_child_file_set_created(child, ticks.QuadPart);
+
   truxton_child_file_set_created( child, now );
   truxton_child_file_set_accessed(child, ticks.QuadPart);
+
   truxton_child_file_set_accessed( child, now );
   truxton_child_file_set_modified(child, ticks.QuadPart);
+
   truxton_child_file_set_modified( child, now );
  
   truxton_child_file_set_origin(child, ORIGIN_GENERATED);
+
   truxton_child_file_set_origin( child, ORIGIN_GENERATED );
  
   if ( truxton_child_file_save(child) == 0 )
+
   if ( truxton_child_file_save( child ) == 0 )
 
   {
 
   {
 
       printf( "Failed to add child to Truxton\n" );
 
       printf( "Failed to add child to Truxton\n" );
 
   }
 
   }
  
   truxton_child_file_destroy(child);
+
   truxton_child_file_destroy( child );
 
}
 
}
</syntaxhighlight>
+
</source>

Latest revision as of 17:02, 13 April 2024

This creates a child file object that you can populate with information before adding it to Truxton.

Syntax

uint64_t truxton_child_file_create( uint64_t truxton_handle );

Parameters

truxton_handle

The Truxton instance this child file will belong. This handle comes from calling truxton_create().

Return value

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

Sample

void add_folder( uint64_t truxton, uint64_t parent_file )
{
   truxton_start_adding_files( truxton );

   uint64_t child = truxton_child_file_create( truxton );

   char id[40];

   truxton_file_get_id( parent_file, id, sizeof(id) );
   truxton_child_file_set_parent_id( child, id );
   truxton_child_file_set_type( child, Type_Directory );
   truxton_child_file_set_name( child, "Custom Exploits Folder" );

   uint64_t now = truxton_time_now();

   truxton_child_file_set_created( child, now );
   truxton_child_file_set_accessed( child, now );
   truxton_child_file_set_modified( child, now );

   truxton_child_file_set_origin( child, ORIGIN_GENERATED );

   if ( truxton_child_file_save( child ) == 0 )
   {
      printf( "Failed to add child to Truxton\n" );
   }

   truxton_child_file_destroy( child );
}