original_string: public function migrate_file($sourcepath, $filepath = '/', $filename = null, $sortorder = 0, $timecreated = null, $timemodified = null) {
  
          // Normalise Windows paths a bit.
          $sourcepath = str_replace('\\', '/', $sourcepath);
  
          // PARAM_PATH must not be used on full OS path!
          if ($sourcepath !== clean_param($sourcepath, PARAM_PATH)) {
              throw new moodle1_convert_exception('file_invalid_path', $sourcepath);
          }
  
          $sourcefullpath = $this->basepath.'/'.$sourcepath;
  
          if (!is_readable($sourcefullpath)) {
              throw new moodle1_convert_exception('file_not_readable', $sourcefullpath);
          }
  
          // sanitize filepath
          if (empty($filepath)) {
              $filepath = '/';
          }
          if (substr($filepath, -1) !== '/') {
              $filepath .= '/';
          }
          $filepath = clean_param($filepath, PARAM_PATH);
  
          if (core_text::strlen($filepath) > 255) {
              throw new moodle1_convert_exception('file_path_longer_than_255_chars');
          }
  
          if (is_null($filename)) {
              $filename = basename($sourcefullpath);
          }
  
          $filename = clean_param($filename, PARAM_FILE);
  
          if ($filename === '') {
              throw new moodle1_convert_exception('unsupported_chars_in_filename');
          }
  
          if (is_null($timecreated)) {
              $timecreated = filectime($sourcefullpath);
          }
  
          if (is_null($timemodified)) {
              $timemodified = filemtime($sourcefullpath);
          }
  
          $filerecord = $this->make_file_record(array(
              'filepath'      => $filepath,
              'filename'      => $filename,
              'sortorder'     => $sortorder,
              'mimetype'      => mimeinfo('type', $sourcefullpath),
              'timecreated'   => $timecreated,
              'timemodified'  => $timemodified,
          ));
  
          list($filerecord['contenthash'], $filerecord['filesize'], $newfile) = $this->add_file_to_pool($sourcefullpath);
          $this->stash_file($filerecord);
  
          return $filerecord['id'];
      }
code: public function migrate_file($sourcepath, $filepath = '/', $filename = null, $sortorder = 0, $timecreated = null, $timemodified = null) {
  
          // Normalise Windows paths a bit.
          $sourcepath = str_replace('\\', '/', $sourcepath);
  
          // PARAM_PATH must not be used on full OS path!
          if ($sourcepath !== clean_param($sourcepath, PARAM_PATH)) {
              throw new moodle1_convert_exception('file_invalid_path', $sourcepath);
          }
  
          $sourcefullpath = $this->basepath.'/'.$sourcepath;
  
          if (!is_readable($sourcefullpath)) {
              throw new moodle1_convert_exception('file_not_readable', $sourcefullpath);
          }
  
          // sanitize filepath
          if (empty($filepath)) {
              $filepath = '/';
          }
          if (substr($filepath, -1) !== '/') {
              $filepath .= '/';
          }
          $filepath = clean_param($filepath, PARAM_PATH);
  
          if (core_text::strlen($filepath) > 255) {
              throw new moodle1_convert_exception('file_path_longer_than_255_chars');
          }
  
          if (is_null($filename)) {
              $filename = basename($sourcefullpath);
          }
  
          $filename = clean_param($filename, PARAM_FILE);
  
          if ($filename === '') {
              throw new moodle1_convert_exception('unsupported_chars_in_filename');
          }
  
          if (is_null($timecreated)) {
              $timecreated = filectime($sourcefullpath);
          }
  
          if (is_null($timemodified)) {
              $timemodified = filemtime($sourcefullpath);
          }
  
          $filerecord = $this->make_file_record(array(
              'filepath'      => $filepath,
              'filename'      => $filename,
              'sortorder'     => $sortorder,
              'mimetype'      => mimeinfo('type', $sourcefullpath),
              'timecreated'   => $timecreated,
              'timemodified'  => $timemodified,
          ));
  
          list($filerecord['contenthash'], $filerecord['filesize'], $newfile) = $this->add_file_to_pool($sourcefullpath);
          $this->stash_file($filerecord);
  
          return $filerecord['id'];
      }
code_tokens: public function migrate_file ( $ sourcepath , $ filepath = '/' , $ filename = null , $ sortorder = 0 , $ timecreated = null , $ timemodified = null ) { // Normalise Windows paths a bit. $ sourcepath = str_replace ( '\\' , '/' , $ sourcepath ) ; // PARAM_PATH must not be used on full OS path! if ( $ sourcepath !== clean_param ( $ sourcepath , PARAM_PATH ) ) { throw new moodle1_convert_exception ( 'file_invalid_path' , $ sourcepath ) ; } $ sourcefullpath = $ this -> basepath . '/' . $ sourcepath ; if ( ! is_readable ( $ sourcefullpath ) ) { throw new moodle1_convert_exception ( 'file_not_readable' , $ sourcefullpath ) ; } // sanitize filepath if ( empty ( $ filepath ) ) { $ filepath = '/' ; } if ( substr ( $ filepath , - 1 ) !== '/' ) { $ filepath .= '/' ; } $ filepath = clean_param ( $ filepath , PARAM_PATH ) ; if ( core_text :: strlen ( $ filepath ) > 255 ) { throw new moodle1_convert_exception ( 'file_path_longer_than_255_chars' ) ; } if ( is_null ( $ filename ) ) { $ filename = basename ( $ sourcefullpath ) ; } $ filename = clean_param ( $ filename , PARAM_FILE ) ; if ( $ filename === '' ) { throw new moodle1_convert_exception ( 'unsupported_chars_in_filename' ) ; } if ( is_null ( $ timecreated ) ) { $ timecreated = filectime ( $ sourcefullpath ) ; } if ( is_null ( $ timemodified ) ) { $ timemodified = filemtime ( $ sourcefullpath ) ; } $ filerecord = $ this -> make_file_record ( array ( 'filepath' => $ filepath , 'filename' => $ filename , 'sortorder' => $ sortorder , 'mimetype' => mimeinfo ( 'type' , $ sourcefullpath ) , 'timecreated' => $ timecreated , 'timemodified' => $ timemodified , ) ) ; list ( $ filerecord [ 'contenthash' ] , $ filerecord [ 'filesize' ] , $ newfile ) = $ this -> add_file_to_pool ( $ sourcefullpath ) ; $ this -> stash_file ( $ filerecord ) ; return $ filerecord [ 'id' ] ; }
docstring: Migrates one given file stored on disk
  
  @param string $sourcepath the path to the source local file within the backup archive {@example 'moddata/foobar/file.ext'}
  @param string $filepath the file path of the migrated file, defaults to the root directory '/' {@example '/sub/dir/'}
  @param string $filename the name of the migrated file, defaults to the same as the source file has
  @param int $sortorder the sortorder of the file (main files have sortorder set to 1)
  @param int $timecreated override the timestamp of when the migrated file should appear as created
  @param int $timemodified override the timestamp of when the migrated file should appear as modified
  @return int id of the migrated file
docstring_tokens: Migrates one given file stored on disk