def curlFile(url, destdir, filename, quiet):
    "download file with curl from 'url' into 'destdir', if filename is given to the file specified"
    curl = CraftCore.cache.findApplication('curl')
    command = [curl, '-C', '-', '--retry', '10', '-L', '--ftp-ssl', '--fail']
    cert = os.path.join(CraftCore.standardDirs.etcDir(), 'cacert.pem')
    if os.path.exists(cert):
        command += ['--cacert', cert]
    command += ['--max-redirs', '50']
    command += ['-o', os.path.join(destdir, filename)]
    command += [url]
    CraftCore.log.debug('curlfile called')
    if (CraftCore.debug.verbose() < 1):
        if quiet:
            with io.StringIO() as tmp:
                ciMode = CraftCore.settings.getboolean('ContinuousIntegration', 'Enabled', False)
                if ciMode:
                    command += ['-v']
                if (not utils.system(command, logCommand=ciMode, stdout=tmp, stderr=subprocess.STDOUT)):
                    CraftCore.log.warning(tmp.getvalue())
                    return False
                if ciMode:
                    loc = re.findall('Host: ([^\\s]+)', tmp.getvalue())
                    if loc:
                        CraftCore.log.info(f'Downloaded from: {loc[(- 1)]}')
                return True
        elif CraftCore.cache.checkCommandOutputFor(curl, '--progress-bar'):
            command += ['--progress-bar']
            CraftCore.log.info(f'curl {url}')
            return utils.system(command, displayProgress=True, logCommand=False, stderr=subprocess.STDOUT)
    command += ['-v']
    return utils.system(command)
download file with curl from 'url' into 'destdir', if filename is given to the file specified
def curlFile(url, destdir, filename, quiet):
    
    curl = CraftCore.cache.findApplication('curl')
    command = [curl, '-C', '-', '--retry', '10', '-L', '--ftp-ssl', '--fail']
    cert = os.path.join(CraftCore.standardDirs.etcDir(), 'cacert.pem')
    if os.path.exists(cert):
        command += ['--cacert', cert]
    command += ['--max-redirs', '50']
    command += ['-o', os.path.join(destdir, filename)]
    command += [url]
    CraftCore.log.debug('curlfile called')
    if (CraftCore.debug.verbose() < 1):
        if quiet:
            with io.StringIO() as tmp:
                ciMode = CraftCore.settings.getboolean('ContinuousIntegration', 'Enabled', False)
                if ciMode:
                    command += ['-v']
                if (not utils.system(command, logCommand=ciMode, stdout=tmp, stderr=subprocess.STDOUT)):
                    CraftCore.log.warning(tmp.getvalue())
                    return False
                if ciMode:
                    loc = re.findall('Host: ([^\\s]+)', tmp.getvalue())
                    if loc:
                        CraftCore.log.info(f'Downloaded from: {loc[(- 1)]}')
                return True
        elif CraftCore.cache.checkCommandOutputFor(curl, '--progress-bar'):
            command += ['--progress-bar']
            CraftCore.log.info(f'curl {url}')
            return utils.system(command, displayProgress=True, logCommand=False, stderr=subprocess.STDOUT)
    command += ['-v']
    return utils.system(command)