original_string: protected function add_file_to_pool($pathname) {
  
          if (!is_readable($pathname)) {
              throw new moodle1_convert_exception('file_not_readable');
          }
  
          $contenthash = file_storage::hash_from_path($pathname);
          $filesize    = filesize($pathname);
          $hashpath    = $this->converter->get_workdir_path().'/files/'.substr($contenthash, 0, 2);
          $hashfile    = "$hashpath/$contenthash";
  
          if (file_exists($hashfile)) {
              if (filesize($hashfile) !== $filesize) {
                  // congratulations! you have found two files with different size and the same
                  // content hash. or, something were wrong (which is more likely)
                  throw new moodle1_convert_exception('same_hash_different_size');
              }
              $newfile = false;
  
          } else {
              check_dir_exists($hashpath);
              $newfile = true;
  
              if (!copy($pathname, $hashfile)) {
                  throw new moodle1_convert_exception('unable_to_copy_file');
              }
  
              if (filesize($hashfile) !== $filesize) {
                  throw new moodle1_convert_exception('filesize_different_after_copy');
              }
          }
  
          return array($contenthash, $filesize, $newfile);
      }
code: protected function add_file_to_pool($pathname) {
  
          if (!is_readable($pathname)) {
              throw new moodle1_convert_exception('file_not_readable');
          }
  
          $contenthash = file_storage::hash_from_path($pathname);
          $filesize    = filesize($pathname);
          $hashpath    = $this->converter->get_workdir_path().'/files/'.substr($contenthash, 0, 2);
          $hashfile    = "$hashpath/$contenthash";
  
          if (file_exists($hashfile)) {
              if (filesize($hashfile) !== $filesize) {
                  // congratulations! you have found two files with different size and the same
                  // content hash. or, something were wrong (which is more likely)
                  throw new moodle1_convert_exception('same_hash_different_size');
              }
              $newfile = false;
  
          } else {
              check_dir_exists($hashpath);
              $newfile = true;
  
              if (!copy($pathname, $hashfile)) {
                  throw new moodle1_convert_exception('unable_to_copy_file');
              }
  
              if (filesize($hashfile) !== $filesize) {
                  throw new moodle1_convert_exception('filesize_different_after_copy');
              }
          }
  
          return array($contenthash, $filesize, $newfile);
      }
code_tokens: protected function add_file_to_pool ( $ pathname ) { if ( ! is_readable ( $ pathname ) ) { throw new moodle1_convert_exception ( 'file_not_readable' ) ; } $ contenthash = file_storage :: hash_from_path ( $ pathname ) ; $ filesize = filesize ( $ pathname ) ; $ hashpath = $ this -> converter -> get_workdir_path ( ) . '/files/' . substr ( $ contenthash , 0 , 2 ) ; $ hashfile = "$hashpath/$contenthash" ; if ( file_exists ( $ hashfile ) ) { if ( filesize ( $ hashfile ) !== $ filesize ) { // congratulations! you have found two files with different size and the same // content hash. or, something were wrong (which is more likely) throw new moodle1_convert_exception ( 'same_hash_different_size' ) ; } $ newfile = false ; } else { check_dir_exists ( $ hashpath ) ; $ newfile = true ; if ( ! copy ( $ pathname , $ hashfile ) ) { throw new moodle1_convert_exception ( 'unable_to_copy_file' ) ; } if ( filesize ( $ hashfile ) !== $ filesize ) { throw new moodle1_convert_exception ( 'filesize_different_after_copy' ) ; } } return array ( $ contenthash , $ filesize , $ newfile ) ; }
docstring: Copies the given file to the pool directory
  
  Returns an array containing SHA1 hash of the file contents, the file size
  and a flag indicating whether the file was actually added to the pool or whether
  it was already there.
  
  @param string $pathname the full path to the file
  @return array with keys (string)contenthash, (int)filesize, (bool)newfile
docstring_tokens: Copies the given file to the pool directory