/**
  * @see tgz_extractor_handler::tgz_end_file()
  */
 public function tgz_end_file($archivepath, $realpath)
 {
     // Place temp file into storage.
     $fs = get_file_storage();
     $filerecord = array('contextid' => $this->contextid, 'component' => $this->component, 'filearea' => $this->filearea, 'itemid' => $this->itemid);
     $filerecord['filepath'] = $this->pathbase . dirname($archivepath) . '/';
     $filerecord['filename'] = basename($archivepath);
     if ($this->userid) {
         $filerecord['userid'] = $this->userid;
     }
     // Delete existing file (if any) and create new one.
     tgz_packer::delete_existing_file_record($fs, $filerecord);
     $fs->create_file_from_pathname($filerecord, $this->tempfile);
     unlink($this->tempfile);
 }