HAndle eventual fread failed & convert line endings to Unix.

master
Nicky 2015-11-05 14:58:30 +01:00
parent 91b970fd76
commit 7efce9fab9
1 changed files with 32 additions and 28 deletions

View File

@ -251,34 +251,38 @@ void LLScriptRecoverQueue::onCreateScript(const LLUUID& idItem)
std::string strCapsUrl = gAgent.getRegion()->getCapability("UpdateScriptAgent");
std::string buffer;
llstat stat;
if( 0 == LLFile::stat(strFilePath, &stat ) && stat.st_size > 0 )
{
buffer.resize( stat.st_size );
LLFILE *pFile = LLFile::fopen( strFileName, "wb" );
if( pFile )
{
fread( &buffer[0], 1, stat.st_size, pFile );
LLFile::close( pFile );
}
else
{
buffer = "";
LL_WARNS() << "Cannot open " << strFilePath << LL_ENDL;
}
}
else
{
LL_WARNS() << "No access to " << strFilePath << LL_ENDL;
}
LLBufferedAssetUploadInfo::taskUploadFinish_f proc = boost::bind(&LLScriptRecoverQueue::onSavedScript, this, _1, _2, _3, _4 );
LLResourceUploadInfo::ptr_t uploadInfo(new LLScriptAssetUpload( idItem, buffer, proc ) );
LLViewerAssetUpload::EnqueueInventoryUpload(strCapsUrl, uploadInfo);
std::string buffer;
llstat stat;
if( 0 == LLFile::stat(strFilePath, &stat ) && stat.st_size > 0 )
{
buffer.resize( stat.st_size );
LLFILE *pFile = LLFile::fopen( strFileName, "wb" );
if( pFile )
{
if( fread( &buffer[0], 1, stat.st_size, pFile ) != stat.st_size )
{
LL_WARNS() << "Incomplete read of " << strFilePath << LL_ENDL;
buffer = "";
}
LLFile::close( pFile );
}
else
{
buffer = "";
LL_WARNS() << "Cannot open " << strFilePath << LL_ENDL;
}
}
else
{
LL_WARNS() << "No access to " << strFilePath << LL_ENDL;
}
LLBufferedAssetUploadInfo::taskUploadFinish_f proc = boost::bind(&LLScriptRecoverQueue::onSavedScript, this, _1, _2, _3, _4 );
LLResourceUploadInfo::ptr_t uploadInfo(new LLScriptAssetUpload( idItem, buffer, proc ) );
LLViewerAssetUpload::EnqueueInventoryUpload(strCapsUrl, uploadInfo);
}
void LLScriptRecoverQueue::onSavedScript(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response)