Difference between revisions of "Truxton location save"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This will commit the data in the location object to the database. It will write a record to the <code><nowiki>[</nowiki>Location<nowiki>]</nowiki></code> ta...")
 
Line 10: Line 10:
 
==<code>location</code>==
 
==<code>location</code>==
 
The handle to the location object.
 
The handle to the location object.
This handle comes from calling <code>[[truxton_location_create]]()</code> or <code>[[truxton_child_file_create_location]].
+
This handle comes from calling <code>[[truxton_location_create]]()</code> or <code>[[truxton_child_file_create_location]]()</code>.
  
 
=Return value=
 
=Return value=
Line 16: Line 16:
  
 
=Remarks=
 
=Remarks=
After this call succeeds, the <code>[[truxton_location_id]]()</code>.
+
After this call succeeds, the <code>[[truxton_location_get_id]]()</code>.
  
 
=Sample=
 
=Sample=
<source lang="C" highlight="30">
+
<source lang="C" highlight="5">
void add_folder(uint64_t truxton, uint64_t parent_file)
+
void new_location(uint64_t truxton, uint64_t file, double latitude, double longitude, double altitude, uint64_t when)
 
{
 
{
   truxton_start_adding_files(truxton);
+
   char guid_string[ 40 ];
  
   uint64_t child = truxton_child_file_create(truxton);
+
   uint64_t location = truxton_location_create(truxton);
  
   char id[40];
+
   truxton_file_get_id( file, guid_string, sizeof( guid_string ) );
 +
  truxton_location_set_file_id( location, guid_string );
  
   truxton_file_get_id(parent_file, id, sizeof(id));
+
   truxton_file_get_media_id( file, guid_string, sizeof( guid_string ) );
   truxton_child_file_set_parent_id(child, id);
+
   truxton_location_set_media_id( location, guid_string );
  truxton_child_file_set_type(child, Type_Directory);
 
  truxton_child_file_set_name(child, "Custom Exploits Folder");
 
  
   FILETIME now;
+
   truxton_location_set_latitude( location, latitude );
 +
  truxton_location_set_longitude( location, longitude );
 +
  truxton_location_set_altitude( location, altitude );
 +
  truxton_location_set_when( location, when );
 +
  truxton_location_set_type( location, LOCATION_TYPE_EXIF );
  
   GetSystemTimePreciseAsFileTime(&now);
+
   if ( truxton_location_save() == 0 )
 
+
   {
  ULARGE_INTEGER ticks;
+
      printf( "Failed to create new location\n" );
 
+
  }
  ticks.LowPart = now.dwLowDateTime;
+
   else
  ticks.HighPart = now.dwHighDateTime;
 
 
 
  truxton_child_file_set_created(child, ticks.QuadPart);
 
  truxton_child_file_set_accessed(child, ticks.QuadPart);
 
   truxton_child_file_set_modified(child, ticks.QuadPart);
 
 
 
  truxton_child_file_set_origin(child, ORIGIN_GENERATED);
 
  truxton_child_file_set_media_id(child, "B57140A0-8E84-4500-B4D5-3606AA8560AA" );
 
 
 
   if ( truxton_child_file_save(child) == 0 )
 
 
   {
 
   {
       printf( "Failed to add child to Truxton\n" );
+
      truxton_location_get_id( location, guid_string, sizeof( guid_string ) );
 +
       printf( "Created new location as id %s\n", guid_string );
 
   }
 
   }
  
   truxton_child_file_destroy(child);
+
   truxton_location_destroy(location);
 
}
 
}
 
</source>
 
</source>

Revision as of 07:55, 13 December 2020

This will commit the data in the location object to the database. It will write a record to the [Location] table.

Syntax

int truxton_location_save( uint64_t location );

Parameters

location

The handle to the location object. This handle comes from calling truxton_location_create() or truxton_child_file_create_location().

Return value

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

Remarks

After this call succeeds, the truxton_location_get_id().

Sample

void new_location(uint64_t truxton, uint64_t file, double latitude, double longitude, double altitude, uint64_t when)
{
   char guid_string[ 40 ];

   uint64_t location = truxton_location_create(truxton);

   truxton_file_get_id( file, guid_string, sizeof( guid_string ) );
   truxton_location_set_file_id( location, guid_string );

   truxton_file_get_media_id( file, guid_string, sizeof( guid_string ) );
   truxton_location_set_media_id( location, guid_string );

   truxton_location_set_latitude( location, latitude );
   truxton_location_set_longitude( location, longitude );
   truxton_location_set_altitude( location, altitude );
   truxton_location_set_when( location, when );
   truxton_location_set_type( location, LOCATION_TYPE_EXIF );

   if ( truxton_location_save() == 0 )
   {
      printf( "Failed to create new location\n" );
   }
   else
   {
      truxton_location_get_id( location, guid_string, sizeof( guid_string ) );
      printf( "Created new location as id %s\n", guid_string );
   }

   truxton_location_destroy(location);
}