// Give the user an overwrite warning if the target file exists const sal_Int32 openFlags = osl_File_OpenFlag_Write | osl_File_OpenFlag_Create; do
{
rc = osl_openFile(out.File.pData, &out.FileHandle, openFlags);
staticbool curl_run(std::u16string_view rURL, OutData& out, const OString& aProxyHost, sal_Int32 nProxyPort)
{ /* Need to investigate further whether it is necessary to call *curl_global_initornot-leaveitfornow(astheftpUCBcontent *providerdoesaswell).
*/
CURL * pCURL = curl_easy_init(); bool ret = false;
if( out.Offset > 0 )
{ // curl_off_t offset = nOffset; libcurl seems to be compiled with large // file support (and we not) ..
sal_Int64 offset = static_cast<sal_Int64>(out.Offset);
(void)curl_easy_setopt(pCURL, CURLOPT_RESUME_FROM_LARGE, offset);
}
CURLcode cc = curl_easy_perform(pCURL);
// treat zero byte downloads as errors if( nullptr == out.FileHandle )
openFile(out);
if( CURLE_OK == cc )
{
out.Handler->downloadFinished(out.File);
ret = true;
}
if ( CURLE_PARTIAL_FILE == cc )
{ // this sometimes happens, when a user throws away his user data, but has already // completed the download of an update.
curl_off_t nDownloadSize;
curl_easy_getinfo( pCURL, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &nDownloadSize ); if ( -1 == nDownloadSize )
{
out.Handler->downloadFinished(out.File);
ret = true;
}
}
// Avoid target file being removed elseif( (CURLE_ABORTED_BY_CALLBACK == cc) || out.StopCondition.check() )
ret = true;
// Only report errors when not stopped else
{
OString aMessage("Unknown error"_ostr);
// when rFile is empty, there is no remembered file name. If there is already a file with the // same name ask the user if she wants to resume a download or restart the download if ( aFile.isEmpty() )
{ // GetFileName()
OUString aURL( rURL ); // ensure no trailing '/'
sal_Int32 nLen = aURL.getLength(); while( (nLen > 0) && ('/' == aURL[ nLen-1 ]) )
aURL = aURL.copy( 0, --nLen );
// extract file name last '/'
sal_Int32 nIndex = aURL.lastIndexOf('/');
aFile = rDestinationDir + aURL.subView( nIndex );
if( osl_File_E_None == rc )
{ // Set file pointer to the end of the file on resume if( osl_File_E_None == osl_setFilePos(out.FileHandle, osl_Pos_End, 0) )
{
osl_getFilePos(out.FileHandle, &out.Offset);
}
} elseif( osl_File_E_NOENT == rc ) // file has been deleted meanwhile ..
out.File.clear();
}
// #i90930# Don't remove already downloaded bits, when curl_run reports an error // because later calls might be successful // if( ! ret ) // osl_removeFile(out.File.pData);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet am 2026-10-05)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.