Filefield

With this import there were files indexed (and not). Inputting them with nodes properly in the new Drupal install was important. Another bonus here is the files were moved into the new Drupal /files directory structure as well.

For our individual 'uploads' the array was created:-

function _x_node_create_file($file, $description = '', $abs = FALSE) {
  if (! $abs) {
    $filepath = $file;
    $file = XOOPS_FILES.$file;
  }
  else {
    $filepath = drupal_substr($file, drupal_strlen(XOOPS_FILES));
  }

  $cur_img = array(
        'filename' => drupal_substr($file, strrpos($file, '/')+1),
        'filepath' => $file,
        'filesize' => filesize($file),
        'fid' => 'upload',
        'xoops_filepath' => $filepath,
  );
  if ($description != '') {
    $cur_img['description'] = $description;
  }
  $cur_img['filemime'] = mimedetect_mime($cur_img);

  return $cur_img;
}

Setting the 'fid' to upload makes the upload module treat the file as if it was in the apache uploads tmp directory. So it copies it to the new location and deletes it. Handy again as it was then clear which files were not referenced anywhere.

The mimedetect module is used here to add the filemime. If the file had come through apache there would be an environment variable for this. The mime could (sometimes) be taken from the previous database, but not always and I wasn't going to trust it to be correct.