original_string: private function copy_area_files(file_storage $fs,
                                       $fromcontextid,
                                       $fromcomponent,
                                       $fromfilearea,
                                       $fromitemid,
                                       $tocontextid,
                                       $tocomponent,
                                       $tofilearea,
                                       $toitemid) {
  
          $newfilerecord = new stdClass();
          $newfilerecord->contextid = $tocontextid;
          $newfilerecord->component = $tocomponent;
          $newfilerecord->filearea = $tofilearea;
          $newfilerecord->itemid = $toitemid;
  
          if ($files = $fs->get_area_files($fromcontextid, $fromcomponent, $fromfilearea, $fromitemid)) {
              foreach ($files as $file) {
                  if ($file->is_directory() and $file->get_filepath() === '/') {
                      // We need a way to mark the age of each draft area.
                      // By not copying the root dir we force it to be created
                      // automatically with current timestamp.
                      continue;
                  }
  
                  $existingfile = $fs->get_file(
                      $newfilerecord->contextid,
                      $newfilerecord->component,
                      $newfilerecord->filearea,
                      $newfilerecord->itemid,
                      $file->get_filepath(),
                      $file->get_filename()
                  );
                  if ($existingfile) {
                      // If the file already exists, remove it so it can be updated.
                      $existingfile->delete();
                  }
  
                  $newfile = $fs->create_file_from_storedfile($newfilerecord, $file);
              }
          }
          return true;
      }
code: private function copy_area_files(file_storage $fs,
                                       $fromcontextid,
                                       $fromcomponent,
                                       $fromfilearea,
                                       $fromitemid,
                                       $tocontextid,
                                       $tocomponent,
                                       $tofilearea,
                                       $toitemid) {
  
          $newfilerecord = new stdClass();
          $newfilerecord->contextid = $tocontextid;
          $newfilerecord->component = $tocomponent;
          $newfilerecord->filearea = $tofilearea;
          $newfilerecord->itemid = $toitemid;
  
          if ($files = $fs->get_area_files($fromcontextid, $fromcomponent, $fromfilearea, $fromitemid)) {
              foreach ($files as $file) {
                  if ($file->is_directory() and $file->get_filepath() === '/') {
                      // We need a way to mark the age of each draft area.
                      // By not copying the root dir we force it to be created
                      // automatically with current timestamp.
                      continue;
                  }
  
                  $existingfile = $fs->get_file(
                      $newfilerecord->contextid,
                      $newfilerecord->component,
                      $newfilerecord->filearea,
                      $newfilerecord->itemid,
                      $file->get_filepath(),
                      $file->get_filename()
                  );
                  if ($existingfile) {
                      // If the file already exists, remove it so it can be updated.
                      $existingfile->delete();
                  }
  
                  $newfile = $fs->create_file_from_storedfile($newfilerecord, $file);
              }
          }
          return true;
      }
code_tokens: private function copy_area_files ( file_storage $ fs , $ fromcontextid , $ fromcomponent , $ fromfilearea , $ fromitemid , $ tocontextid , $ tocomponent , $ tofilearea , $ toitemid ) { $ newfilerecord = new stdClass ( ) ; $ newfilerecord -> contextid = $ tocontextid ; $ newfilerecord -> component = $ tocomponent ; $ newfilerecord -> filearea = $ tofilearea ; $ newfilerecord -> itemid = $ toitemid ; if ( $ files = $ fs -> get_area_files ( $ fromcontextid , $ fromcomponent , $ fromfilearea , $ fromitemid ) ) { foreach ( $ files as $ file ) { if ( $ file -> is_directory ( ) and $ file -> get_filepath ( ) === '/' ) { // We need a way to mark the age of each draft area. // By not copying the root dir we force it to be created // automatically with current timestamp. continue ; } $ existingfile = $ fs -> get_file ( $ newfilerecord -> contextid , $ newfilerecord -> component , $ newfilerecord -> filearea , $ newfilerecord -> itemid , $ file -> get_filepath ( ) , $ file -> get_filename ( ) ) ; if ( $ existingfile ) { // If the file already exists, remove it so it can be updated. $ existingfile -> delete ( ) ; } $ newfile = $ fs -> create_file_from_storedfile ( $ newfilerecord , $ file ) ; } } return true ; }
docstring: Copy all the files from one file area to another.
  
  @param file_storage $fs - The source context id
  @param int $fromcontextid - The source context id
  @param string $fromcomponent - The source component
  @param string $fromfilearea - The source filearea
  @param int $fromitemid - The source item id
  @param int $tocontextid - The destination context id
  @param string $tocomponent - The destination component
  @param string $tofilearea - The destination filearea
  @param int $toitemid - The destination item id
  @return boolean
docstring_tokens: Copy all the files from one file area to another .