Difference between revisions of "Truxton child file create location"

From truxwiki.com
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This creates a geographic location object sourced from this file that you can use in the [[Truxton C API#Geographic Location | Location API.]]
 
This creates a geographic location object sourced from this file that you can use in the [[Truxton C API#Geographic Location | Location API.]]
A location object is how you add records to the <code>[[Location Table | Location]]</code> table.
+
A location object is how you add records to the <code><nowiki>[</nowiki>[[Location Table|Location]]<nowiki>]</nowiki></code> table.
 
The resulting location object will automatically be associated with the file it was created from and with the media the file belongs to.
 
The resulting location object will automatically be associated with the file it was created from and with the media the file belongs to.
  
Line 10: Line 10:
 
=Parameters=
 
=Parameters=
 
==<code>child_handle</code>==
 
==<code>child_handle</code>==
 
 
The handle created by the [[truxton_child_file_create]] or [[truxton_file_create_child]] call.
 
The handle created by the [[truxton_child_file_create]] or [[truxton_file_create_child]] call.
  
 
=Return value=
 
=Return value=
A handle to an location object.
+
A handle to a location object.
  
 
=Sample=
 
=Sample=
 
+
<source lang="C" highlight="21">
<syntaxhighlight lang="C" highlight="21">
+
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" );
  
   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" );
 
   }
 
   }
  
   uint64_t location = truxton_child_file_create_location(child);
+
   uint64_t location = truxton_child_file_create_location( child );
  
   truxton_location_set_latitude(location, 18.30305549975252);
+
   truxton_location_set_latitude( location, 18.30305549975252 );
   truxton_location_set_longitude(location, -64.824006192214);
+
   truxton_location_set_longitude( location, -64.824006192214 );
   truxton_location_set_altitude(location, 1.1);
+
   truxton_location_set_altitude( location, 1.1 );
   truxton_location_set_type(location, LOCATION_TYPE_GOPRO_VIDEO);
+
   truxton_location_set_type( location, LOCATION_TYPE_GOPRO_VIDEO );
   truxton_location_save(location);
+
   truxton_location_save( location );
   truxton_location_destroy(location);
+
   truxton_location_destroy( location );
  
   truxton_child_file_destroy(child);
+
   truxton_child_file_destroy( child );
 
}
 
}
</syntaxhighlight>
+
</source>

Latest revision as of 04:23, 13 February 2021

This creates a geographic location object sourced from this file that you can use in the Location API. A location object is how you add records to the [Location] table. The resulting location object will automatically be associated with the file it was created from and with the media the file belongs to.

Syntax

uint64_t truxton_child_file_create_location( uint64_t child_handle );

Parameters

child_handle

The handle created by the truxton_child_file_create or truxton_file_create_child call.

Return value

A handle to a location object.

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" );

   truxton_child_file_set_origin( child, ORIGIN_GENERATED );

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

   uint64_t location = truxton_child_file_create_location( child );

   truxton_location_set_latitude( location, 18.30305549975252 );
   truxton_location_set_longitude( location, -64.824006192214 );
   truxton_location_set_altitude( location, 1.1 );
   truxton_location_set_type( location, LOCATION_TYPE_GOPRO_VIDEO );
   truxton_location_save( location );
   truxton_location_destroy( location );

   truxton_child_file_destroy( child );
}