D6 - Create a files table entry for a file I have to migrate some content and everything is fine except the images. 

I'm getting the images using file_get_contents() and save the file in the drupal /files folder using the following code: 

    $image = file_get_contents('http://www.someurl.com/xx/util/yy.jpg'); 
    $file = file_save_data($image, 'yy.jpg',FILE_EXISTS_REPLACE); 
    print $file; // returns the path to the file ( /files/yy.jpg )


So the image is uploaded in the /files folder. 

What I'm not able to understand is, how can I add the image to the files table so that I can be able later to use the file object? 

I was looking through the files.inc functions for Drupal 6 but I wasn't able to find anything that could help. 
Should I insert the data manually using db_query()? 

Thanks.
It's just done manually, e.g.:

$file = new stdClass();
$file-&gt;filename = 'foo.bar';
$file-&gt;filepath = $file;
$file-&gt;filemime = file_get_mimetype($file-&gt;filename);
$file-&gt;uid = $user-&gt;uid;
$file-&gt;status = FILE_STATUS_TEMPORARY;
$file-&gt;timestamp = time();
drupal_write_record('files', $file);


See file_save_upload() for a much broader example, including validation.