public function get_file($url, $filename = '') {
        global $CFG;

        $path = $this->prepare_file($filename);
        $c = new curl;

        $result = $c->download_one($url, null, array('filepath' => $path, 'timeout' => $CFG->repositorygetfiletimeout));
        if ($result !== true) {
            throw new moodle_exception('errorwhiledownload', 'repository', '', $result);
        }
        return array('path'=>$path, 'url'=>$url);
    }