本文整理汇总了C++中LLAPRFile::close方法的典型用法代码示例。如果您正苦于以下问题:C++ LLAPRFile::close方法的具体用法?C++ LLAPRFile::close怎么用?C++ LLAPRFile::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLAPRFile
的用法示例。
在下文中一共展示了LLAPRFile::close方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool LLLFSThread::Request::processRequest()
{
bool complete = false;
if (mOperation == FILE_READ)
{
llassert(mOffset >= 0);
LLAPRFile infile ;
infile.open(mFileName, LL_APR_RB, LLAPRFile::local);
if (!infile.getFileHandle())
{
llwarns << "LLLFS: Unable to read file: " << mFileName << llendl;
mBytesRead = 0; // fail
return true;
}
S32 off;
if (mOffset < 0)
off = infile.seek(APR_END, 0);
else
off = infile.seek(APR_SET, mOffset);
llassert_always(off >= 0);
mBytesRead = infile.read(mBuffer, mBytes );
complete = true;
infile.close() ;
// llinfos << "LLLFSThread::READ:" << mFileName << " Bytes: " << mBytesRead << llendl;
}
else if (mOperation == FILE_WRITE)
{
apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY;
if (mOffset < 0)
flags |= APR_APPEND;
LLAPRFile outfile ;
outfile.open(mFileName, flags, LLAPRFile::local);
if (!outfile.getFileHandle())
{
llwarns << "LLLFS: Unable to write file: " << mFileName << llendl;
mBytesRead = 0; // fail
return true;
}
if (mOffset >= 0)
{
S32 seek = outfile.seek(APR_SET, mOffset);
if (seek < 0)
{
llwarns << "LLLFS: Unable to write file (seek failed): " << mFileName << llendl;
mBytesRead = 0; // fail
return true;
}
}
mBytesRead = outfile.write(mBuffer, mBytes );
complete = true;
// llinfos << "LLLFSThread::WRITE:" << mFileName << " Bytes: " << mBytesRead << "/" << mBytes << " Offset:" << mOffset << llendl;
}
else
{
llwarns << "LLLFSThread::unknown operation: " << (S32)mOperation << llendl;
}
return complete;
}
示例2: uploadNextAsset
void LLObjectBackup::uploadNextAsset()
{
if (mTexturesList.empty())
{
llinfos << "Texture list is empty, moving to rez stage." << llendl;
mCurrentAsset = LLUUID::null;
importFirstObject();
return;
}
updateImportNumbers();
std::list<LLUUID>::iterator iter;
iter = mTexturesList.begin();
LLUUID id = *iter;
mTexturesList.pop_front();
llinfos << "Got texture ID " << id << ": trying to upload" << llendl;
mCurrentAsset = id;
std::string struid;
id.toString(struid);
std::string filename = mFolder + "//" + struid;
LLAssetID uuid;
LLTransactionID tid;
// generate a new transaction ID for this asset
tid.generate();
uuid = tid.makeAssetID(gAgent.getSecureSessionID());
S32 file_size;
LLAPRFile outfile;
outfile.open(filename, LL_APR_RB, LLAPRFile::global, &file_size);
if (outfile.getFileHandle())
{
const S32 buf_size = 65536;
U8 copy_buf[buf_size];
LLVFile file(gVFS, uuid, LLAssetType::AT_TEXTURE, LLVFile::WRITE);
file.setMaxSize(file_size);
while ((file_size = outfile.read(copy_buf, buf_size)))
{
file.write(copy_buf, file_size);
}
outfile.close();
}
else
{
llwarns << "Unable to access output file " << filename << llendl;
uploadNextAsset();
return;
}
myupload_new_resource(tid, LLAssetType::AT_TEXTURE, struid, struid, 0,
LLAssetType::AT_TEXTURE, LLInventoryType::defaultForAssetType(LLAssetType::AT_TEXTURE),
0x0, "Uploaded texture", NULL, NULL);
}
示例3: completedRaw
void completedRaw(
const LLChannelDescriptors& channels,
const LLIOPipe::buffer_ptr_t& buffer)
{
completedHeader();
if (!isGoodStatus())
{
if (getStatus() == HTTP_NOT_MODIFIED)
{
LL_INFOS("fsdata") << "Got [304] not modified for " << mURL << LL_ENDL;
}
else
{
LL_WARNS("fsdata") << "Error fetching " << mURL << " Status: [" << getStatus() << "]" << LL_ENDL;
}
return;
}
S32 data_size = buffer->countAfter(channels.in(), NULL);
if (data_size <= 0)
{
LL_WARNS("fsdata") << "Received zero data for " << mURL << LL_ENDL;
return;
}
U8* data = new U8[data_size];
buffer->readAfter(channels.in(), NULL, data, data_size);
// basic check for valid data received
LLXMLNodePtr xml_root;
if ( (!LLXMLNode::parseBuffer(data, data_size, xml_root, NULL)) || (xml_root.isNull()) || (!xml_root->hasName("script_library")) )
{
LL_WARNS("fsdata") << "Could not read the script library data from "<< mURL << LL_ENDL;
delete[] data;
data = NULL;
return;
}
LLAPRFile outfile ;
outfile.open(mFilename, LL_APR_WB);
if (!outfile.getFileHandle())
{
LL_WARNS("fsdata") << "Unable to open file for writing: " << mFilename << LL_ENDL;
}
else
{
LL_INFOS("fsdata") << "Saving " << mFilename << LL_ENDL;
outfile.write(data, data_size);
outfile.close() ;
}
delete[] data;
data = NULL;
}
示例4: exportasdotAnim
void LLPreviewAnim::exportasdotAnim( void *userdata )
{
LLPreviewAnim* self = (LLPreviewAnim*) userdata;
const LLInventoryItem *item = self->getItem();
//LLVOAvatar* avatar = gAgent.getAvatarObject();
//LLMotion* motion = avatar->findMotion(item->getAssetUUID());
//LLKeyframeMotion* motionp = (LLKeyframeMotion*)motion;
//if (motionp)
{
//U32 size = motionp->getFileSize();
//U8* buffer = new U8[size];
//LLDataPackerBinaryBuffer dp(buffer, size);
//if(motionp->serialize(dp))
{
std::string filename = item->getName() + ".animatn";
LLFilePicker& picker = LLFilePicker::instance();
if(!picker.getSaveFile( LLFilePicker::FFSAVE_ALL, filename.c_str() ) )
{
// User canceled save.
return;
}
std::string name = picker.getFirstFile();
std::string save_filename(name);
LLAPRFile infile ;
infile.open(save_filename.c_str(), LL_APR_WB, LLAPRFile::local);
apr_file_t *fp = infile.getFileHandle();
if(fp)infile.write(self->mAnimBuffer, self->mAnimBufferSize);
infile.close();
}
//delete[] buffer;
}
//whole file imported from onyx thomas shikami gets credit for the exporter
}
示例5: convert
// static
LLAssetType::EType LLAssetConverter::convert(std::string src_filename, std::string filename)
{
std::string exten = gDirUtilp->getExtension(src_filename);
LLAssetType::EType asset_type = LLAssetType::AT_NONE;
if (exten.empty())
return LLAssetType::AT_NONE;
else if(exten == "bmp")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerImageList::createUploadFile(src_filename,
filename,
IMG_CODEC_BMP ))
{
return LLAssetType::AT_NONE;
}
}
else if( exten == "tga")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerImageList::createUploadFile(src_filename,
filename,
IMG_CODEC_TGA ))
{
return LLAssetType::AT_NONE;
}
}
else if( exten == "jpg" || exten == "jpeg")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerImageList::createUploadFile(src_filename,
filename,
IMG_CODEC_JPEG ))
{
return LLAssetType::AT_NONE;
}
}
else if( exten == "png")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerImageList::createUploadFile(src_filename,
filename,
IMG_CODEC_PNG ))
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "wav")
{
asset_type = LLAssetType::AT_SOUND;
if(encode_vorbis_file(src_filename, filename) != LLVORBISENC_NOERR)
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "ogg")
{
asset_type = LLAssetType::AT_SOUND;
if(!copyFile(src_filename, filename))
{
return LLAssetType::AT_NONE;
}
}
//else if(exten == "tmp") FIXME
else if (exten == "bvh")
{
asset_type = LLAssetType::AT_ANIMATION;
S32 file_size;
LLAPRFile fp;
fp.open(src_filename, LL_APR_RB, LLAPRFile::global, &file_size);
if(!fp.getFileHandle()) return LLAssetType::AT_NONE;
char* file_buffer = new char[file_size + 1];
if(fp.read(file_buffer, file_size) == 0) //not sure if this is right, gotta check this one
{
fp.close();
delete[] file_buffer;
return LLAssetType::AT_NONE;
}
LLBVHLoader* loaderp = new LLBVHLoader(file_buffer);
if(!loaderp->isInitialized())
{
fp.close();
delete[] file_buffer;
return LLAssetType::AT_NONE;
}
S32 buffer_size = loaderp->getOutputSize();
U8* buffer = new U8[buffer_size];
LLDataPackerBinaryBuffer dp(buffer, buffer_size);
loaderp->serialize(dp);
LLAPRFile apr_file(filename, LL_APR_WB, LLAPRFile::global);
apr_file.write(buffer, buffer_size);
delete[] file_buffer;
delete[] buffer;
fp.close();
apr_file.close();
}
else if (exten == "animatn")
{
asset_type = LLAssetType::AT_ANIMATION;
if(!copyFile(src_filename, filename))
//.........这里部分代码省略.........
示例6: check_for_invalid_wav_formats
S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& error_msg)
{
U16 num_channels = 0;
U32 sample_rate = 0;
U32 bits_per_sample = 0;
U32 physical_file_size = 0;
U32 chunk_length = 0;
U32 raw_data_length = 0;
U32 bytes_per_sec = 0;
BOOL uncompressed_pcm = FALSE;
unsigned char wav_header[44]; /*Flawfinder: ignore*/
error_msg.clear();
// ********************************
LLAPRFile infile ;
infile.open(in_fname,LL_APR_RB);
// ********************************
if (!infile.getFileHandle())
{
error_msg = "CannotUploadSoundFile";
return(LLVORBISENC_SOURCE_OPEN_ERR);
}
infile.read(wav_header, 44);
physical_file_size = infile.seek(APR_END,0);
if (strncmp((char *)&(wav_header[0]),"RIFF",4))
{
error_msg = "SoundFileNotRIFF";
return(LLVORBISENC_WAV_FORMAT_ERR);
}
if (strncmp((char *)&(wav_header[8]),"WAVE",4))
{
error_msg = "SoundFileNotRIFF";
return(LLVORBISENC_WAV_FORMAT_ERR);
}
// parse the chunks
U32 file_pos = 12; // start at the first chunk (usually fmt but not always)
while ((file_pos + 8)< physical_file_size)
{
infile.seek(APR_SET,file_pos);
infile.read(wav_header, 44);
chunk_length = ((U32) wav_header[7] << 24)
+ ((U32) wav_header[6] << 16)
+ ((U32) wav_header[5] << 8)
+ wav_header[4];
if (chunk_length > physical_file_size - file_pos - 4)
{
infile.close();
error_msg = "SoundFileInvalidChunkSize";
return(LLVORBISENC_CHUNK_SIZE_ERR);
}
// llinfos << "chunk found: '" << wav_header[0] << wav_header[1] << wav_header[2] << wav_header[3] << "'" << llendl;
if (!(strncmp((char *)&(wav_header[0]),"fmt ",4)))
{
if ((wav_header[8] == 0x01) && (wav_header[9] == 0x00))
{
uncompressed_pcm = TRUE;
}
num_channels = ((U16) wav_header[11] << 8) + wav_header[10];
sample_rate = ((U32) wav_header[15] << 24)
+ ((U32) wav_header[14] << 16)
+ ((U32) wav_header[13] << 8)
+ wav_header[12];
bits_per_sample = ((U16) wav_header[23] << 8) + wav_header[22];
bytes_per_sec = ((U32) wav_header[19] << 24)
+ ((U32) wav_header[18] << 16)
+ ((U32) wav_header[17] << 8)
+ wav_header[16];
}
else if (!(strncmp((char *)&(wav_header[0]),"data",4)))
{
raw_data_length = chunk_length;
}
file_pos += (chunk_length + 8);
chunk_length = 0;
}
// ****************
infile.close();
// ****************
if (!uncompressed_pcm)
{
error_msg = "SoundFileNotPCM";
return(LLVORBISENC_PCM_FORMAT_ERR);
}
if ((num_channels < 1) || (num_channels > LLVORBIS_CLIP_MAX_CHANNELS))
{
error_msg = "SoundFileInvalidChannelCount";
//.........这里部分代码省略.........
示例7: loadTranslationTable
//.........这里部分代码省略.........
return E_ST_NO_XLT_RELATIVE;
}
}
else
{
return E_ST_NO_XLT_RELATIVE;
}
continue;
}
//----------------------------------------------------------------
// check for outname value
//----------------------------------------------------------------
if ( LLStringUtil::compareInsensitive(token, "outname")==0 )
{
char outName[128]; /* Flawfinder: ignore */
if ( sscanf(mLine, " %*s = %127s", outName) != 1 ) /* Flawfinder: ignore */
return E_ST_NO_XLT_OUTNAME;
trans->mOutName = outName;
continue;
}
//----------------------------------------------------------------
// check for frame matrix value
//----------------------------------------------------------------
if ( LLStringUtil::compareInsensitive(token, "frame")==0 )
{
LLMatrix3 fm;
if ( sscanf(mLine, " %*s = %f %f %f, %f %f %f, %f %f %f",
&fm.mMatrix[0][0], &fm.mMatrix[0][1], &fm.mMatrix[0][2],
&fm.mMatrix[1][0], &fm.mMatrix[1][1], &fm.mMatrix[1][2],
&fm.mMatrix[2][0], &fm.mMatrix[2][1], &fm.mMatrix[2][2] ) != 9 )
return E_ST_NO_XLT_MATRIX;
trans->mFrameMatrix = fm;
continue;
}
//----------------------------------------------------------------
// check for offset matrix value
//----------------------------------------------------------------
if ( LLStringUtil::compareInsensitive(token, "offset")==0 )
{
LLMatrix3 om;
if ( sscanf(mLine, " %*s = %f %f %f, %f %f %f, %f %f %f",
&om.mMatrix[0][0], &om.mMatrix[0][1], &om.mMatrix[0][2],
&om.mMatrix[1][0], &om.mMatrix[1][1], &om.mMatrix[1][2],
&om.mMatrix[2][0], &om.mMatrix[2][1], &om.mMatrix[2][2] ) != 9 )
return E_ST_NO_XLT_MATRIX;
trans->mOffsetMatrix = om;
continue;
}
//----------------------------------------------------------------
// check for mergeparent value
//----------------------------------------------------------------
if ( LLStringUtil::compareInsensitive(token, "mergeparent")==0 )
{
char mergeParentName[128]; /* Flawfinder: ignore */
if ( sscanf(mLine, " %*s = %127s", mergeParentName) != 1 ) /* Flawfinder: ignore */
return E_ST_NO_XLT_MERGEPARENT;
trans->mMergeParentName = mergeParentName;
continue;
}
//----------------------------------------------------------------
// check for mergechild value
//----------------------------------------------------------------
if ( LLStringUtil::compareInsensitive(token, "mergechild")==0 )
{
char mergeChildName[128]; /* Flawfinder: ignore */
if ( sscanf(mLine, " %*s = %127s", mergeChildName) != 1 ) /* Flawfinder: ignore */
return E_ST_NO_XLT_MERGECHILD;
trans->mMergeChildName = mergeChildName;
continue;
}
//----------------------------------------------------------------
// check for per-joint priority
//----------------------------------------------------------------
if ( LLStringUtil::compareInsensitive(token, "priority")==0 )
{
S32 priority;
if ( sscanf(mLine, " %*s = %d", &priority) != 1 )
return E_ST_NO_XLT_PRIORITY;
trans->mPriorityModifier = priority;
continue;
}
}
infile.close() ;
return E_ST_OK;
}
示例8: loadMotions
//-----------------------------------------------------------------------------
// loadMotions()
//-----------------------------------------------------------------------------
BOOL LLKeyframeMotionParam::loadMotions()
{
//-------------------------------------------------------------------------
// Load named file by concatenating the character prefix with the motion name.
// Load data into a buffer to be parsed.
//-------------------------------------------------------------------------
std::string path = gDirUtilp->getExpandedFilename(LL_PATH_MOTIONS,mCharacter->getAnimationPrefix())
+ "_" + getName() + ".llp";
//-------------------------------------------------------------------------
// open the file
//-------------------------------------------------------------------------
S32 fileSize = 0;
LLAPRFile infile ;
infile.open(path, LL_APR_R, NULL, &fileSize);
apr_file_t* fp = infile.getFileHandle() ;
if (!fp || fileSize == 0)
{
llinfos << "ERROR: can't open: " << path << llendl;
return FALSE;
}
// allocate a text buffer
char *text = new char[ fileSize+1 ];
if ( !text )
{
llinfos << "ERROR: can't allocated keyframe text buffer." << llendl;
return FALSE;
}
//-------------------------------------------------------------------------
// load data from file into buffer
//-------------------------------------------------------------------------
bool error = false;
char *p = text;
while ( 1 )
{
if (apr_file_eof(fp) == APR_EOF)
{
break;
}
if (apr_file_gets(p, 1024, fp) != APR_SUCCESS)
{
error = true;
break;
}
while ( *(++p) )
;
}
//-------------------------------------------------------------------------
// close the file
//-------------------------------------------------------------------------
infile.close();
//-------------------------------------------------------------------------
// check for error
//-------------------------------------------------------------------------
llassert( p <= (text+fileSize) );
if ( error )
{
llinfos << "ERROR: error while reading from " << path << llendl;
delete [] text;
return FALSE;
}
llinfos << "Loading parametric keyframe data for: " << getName() << llendl;
//-------------------------------------------------------------------------
// parse the text and build keyframe data structures
//-------------------------------------------------------------------------
p = text;
S32 num;
char strA[80]; /* Flawfinder: ignore */
char strB[80]; /* Flawfinder: ignore */
F32 floatA = 0.0f;
//-------------------------------------------------------------------------
// get priority
//-------------------------------------------------------------------------
BOOL isFirstMotion = TRUE;
num = sscanf(p, "%79s %79s %f", strA, strB, &floatA); /* Flawfinder: ignore */
while(1)
{
if (num == 0 || num == EOF) break;
if ((num != 3))
{
llinfos << "WARNING: can't read parametric motion" << llendl;
delete [] text;
return FALSE;
}
addKeyframeMotion(strA, gAnimLibrary.stringToAnimState(std::string(strA)), strB, floatA);
if (isFirstMotion)
//.........这里部分代码省略.........
示例9: convert
LLAssetType::EType LLAssetConverter::convert(std::string src_filename, std::string filename)
{
std::string exten = gDirUtilp->getExtension(src_filename);
LLAssetType::EType asset_type = LLAssetType::AT_NONE;
if (exten.empty())
return LLAssetType::AT_NONE;
else if(exten == "bmp")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_BMP ))
{
return LLAssetType::AT_NONE;
}
}
else if( exten == "tga")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_TGA ))
{
return LLAssetType::AT_NONE;
}
}
else if( exten == "jpg" || exten == "jpeg")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_JPEG ))
{
return LLAssetType::AT_NONE;
}
}
else if( exten == "png")
{
asset_type = LLAssetType::AT_TEXTURE;
if (!LLViewerTextureList::createUploadFile(src_filename,
filename,
IMG_CODEC_PNG ))
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "wav")
{
asset_type = LLAssetType::AT_SOUND;
if(encode_vorbis_file(src_filename, filename) != LLVORBISENC_NOERR)
{
return LLAssetType::AT_NONE;
}
}
else if(exten == "ogg")
{
asset_type = LLAssetType::AT_SOUND;
if(!copyFile(src_filename, filename))
{
return LLAssetType::AT_NONE;
}
}
//else if(exten == "tmp") FIXME
else if (exten == "bvh")
{
asset_type = LLAssetType::AT_ANIMATION;
S32 file_size;
LLAPRFile fp;
fp.open(src_filename, LL_APR_RB, LLAPRFile::global, &file_size);
if(!fp.getFileHandle()) return LLAssetType::AT_NONE;
char* file_buffer = new char[file_size + 1];
ELoadStatus load_status = E_ST_OK;
S32 line_number = 0;
LLBVHLoader* loaderp = new LLBVHLoader(file_buffer, load_status, line_number);
if(load_status == E_ST_NO_XLT_FILE)
{
llwarns << "NOTE: No translation table found." << llendl;
}
else
{
llwarns << "ERROR: [line: " << line_number << "] " << STATUS[load_status].c_str() << llendl;
}
S32 buffer_size = loaderp->getOutputSize();
U8* buffer = new U8[buffer_size];
LLDataPackerBinaryBuffer dp(buffer, buffer_size);
loaderp->serialize(dp);
LLAPRFile apr_file(filename, LL_APR_WB, LLAPRFile::global);
apr_file.write(buffer, buffer_size);
delete[] file_buffer;
delete[] buffer;
fp.close();
apr_file.close();
}
else if (exten == "animatn")
{
asset_type = LLAssetType::AT_ANIMATION;
if(!copyFile(src_filename, filename))
{
//.........这里部分代码省略.........
示例10: loadMotions
//-----------------------------------------------------------------------------
// loadMotions()
//-----------------------------------------------------------------------------
BOOL LLKeyframeMotionParam::loadMotions()
{
//-------------------------------------------------------------------------
// Load named file by concatenating the character prefix with the motion name.
// Load data into a buffer to be parsed.
//-------------------------------------------------------------------------
//std::string path = gDirUtilp->getExpandedFilename(LL_PATH_MOTIONS,mCharacter->getAnimationPrefix())
// + "_" + getName() + ".llp";
//RN: deprecated unused reference to "motion" directory
std::string path;
//-------------------------------------------------------------------------
// open the file
//-------------------------------------------------------------------------
S32 fileSize = 0;
LLAPRFile infile ;
infile.open(path, LL_APR_R, NULL, &fileSize);
// <FS:ND> Remove LLVolatileAPRPool/apr_file_t and use FILE* instead
// apr_file_t* fp = infile.getFileHandle() ;
LLAPRFile::tFiletype* fp = infile.getFileHandle() ;
// </FS:ND>
if (!fp || fileSize == 0)
{
LL_INFOS() << "ERROR: can't open: " << path << LL_ENDL;
return FALSE;
}
// allocate a text buffer
std::vector<char> text(fileSize+1);
//-------------------------------------------------------------------------
// load data from file into buffer
//-------------------------------------------------------------------------
bool error = false;
char *p = &text[0];
while ( 1 )
{
if (apr_file_eof(fp) == APR_EOF)
{
break;
}
if (apr_file_gets(p, 1024, fp) != APR_SUCCESS)
{
error = true;
break;
}
while ( *(++p) )
;
}
//-------------------------------------------------------------------------
// close the file
//-------------------------------------------------------------------------
infile.close();
//-------------------------------------------------------------------------
// check for error
//-------------------------------------------------------------------------
llassert( p <= (&text[0] + fileSize) );
if ( error )
{
LL_INFOS() << "ERROR: error while reading from " << path << LL_ENDL;
return FALSE;
}
LL_INFOS() << "Loading parametric keyframe data for: " << getName() << LL_ENDL;
//-------------------------------------------------------------------------
// parse the text and build keyframe data structures
//-------------------------------------------------------------------------
p = &text[0];
S32 num;
char strA[80]; /* Flawfinder: ignore */
char strB[80]; /* Flawfinder: ignore */
F32 floatA = 0.0f;
//-------------------------------------------------------------------------
// get priority
//-------------------------------------------------------------------------
BOOL isFirstMotion = TRUE;
num = sscanf(p, "%79s %79s %f", strA, strB, &floatA); /* Flawfinder: ignore */
while(1)
{
if (num == 0 || num == EOF) break;
if ((num != 3))
{
LL_INFOS() << "WARNING: can't read parametric motion" << LL_ENDL;
return FALSE;
}
addKeyframeMotion(strA, gAnimLibrary.stringToAnimState(std::string(strA)), strB, floatA);
//.........这里部分代码省略.........
示例11: postBuild
//.........这里部分代码省略.........
//childSetCommitCallback("ease_in_time", onCommitEaseIn, this);
//childSetValidate("ease_in_time", validateEaseIn);
//childSetCommitCallback("ease_out_time", onCommitEaseOut, this);
//childSetValidate("ease_out_time", validateEaseOut);
std::string exten = gDirUtilp->getExtension(mFilename);
if (exten == "bvh")
{
// loading a bvh file
// now load bvh file
S32 file_size;
LLAPRFile infile ;
infile.open(mFilenameAndPath, LL_APR_RB, LLAPRFile::global, &file_size);
if (!infile.getFileHandle())
{
llwarns << "Can't open BVH file:" << mFilename << llendl;
}
else
{
char* file_buffer;
file_buffer = new char[file_size + 1];
if (file_size == infile.read(file_buffer, file_size))
{
file_buffer[file_size] = '\0';
llinfos << "Loading BVH file " << mFilename << llendl;
loaderp = new LLBVHLoader(file_buffer);
}
infile.close() ;
delete[] file_buffer;
}
}
if (loaderp && loaderp->isInitialized() && loaderp->getDuration() <= MAX_ANIM_DURATION)
{
// generate unique id for this motion
mTransactionID.generate();
mMotionID = mTransactionID.makeAssetID(gAgent.getSecureSessionID());
mAnimPreview = new LLPreviewAnimation(256, 256);
// motion will be returned, but it will be in a load-pending state, as this is a new motion
// this motion will not request an asset transfer until next update, so we have a chance to
// load the keyframe data locally
motionp = (LLKeyframeMotion*)mAnimPreview->getDummyAvatar()->createMotion(mMotionID);
// create data buffer for keyframe initialization
S32 buffer_size = loaderp->getOutputSize();
U8* buffer = new U8[buffer_size];
LLDataPackerBinaryBuffer dp(buffer, buffer_size);
// pass animation data through memory buffer
loaderp->serialize(dp);
dp.reset();
BOOL success = motionp && motionp->deserialize(dp);
delete []buffer;
if (success)
{
示例12: upload_next_asset
void primbackup::upload_next_asset()
{
if(textures.empty())
{
llinfos<<" Texture list is empty, moving to rez statge"<< llendl;
current_asset=LLUUID::null;
import_object1a();
return;
}
this->updateimportnumbers();
std::list<LLUUID>::iterator iter;
iter=textures.begin();
LLUUID id=(*iter);
textures.pop_front();
llinfos<<"Got texture ID "<<id<< "trying to upload"<<llendl;
current_asset=id;
std::string struid;
id.toString(struid);
std::string filename=folder+"//"+struid;
LLAssetID uuid;
LLTransactionID tid;
// gen a new transaction ID for this asset
tid.generate();
uuid = tid.makeAssetID(gAgent.getSecureSessionID());
S32 file_size;
apr_file_t* fp;
LLAPRFile aFile;
aFile.open(filename, LL_APR_RB, LLAPRFile::global, &file_size);
fp = aFile.getFileHandle();
if (fp)
{
const S32 buf_size = 65536;
U8 copy_buf[buf_size];
LLVFile file(gVFS, uuid, LLAssetType::AT_TEXTURE, LLVFile::WRITE);
file.setMaxSize(file_size);
while ((file_size =aFile.read(copy_buf, buf_size)))
{
file.write(copy_buf, file_size);
}
aFile.close();
}
else
{
llwarns<<"Unable to access output file "<<filename<<llendl;
upload_next_asset();
return;
}
myupload_new_resource(
tid, LLAssetType::AT_TEXTURE, struid,
struid, 0,
LLAssetType::AT_TEXTURE,
LLInventoryType::defaultForAssetType(LLAssetType::AT_TEXTURE),
0x0,
"Uploaded texture",
NULL,
NULL);
}
示例13: upload_new_resource
//.........这里部分代码省略.........
else if(exten == "tmp")
{
// This is a generic .lin resource file
asset_type = LLAssetType::AT_OBJECT;
LLFILE* in = LLFile::fopen(src_filename, "rb"); /* Flawfinder: ignore */
if (in)
{
// read in the file header
char buf[16384]; /* Flawfinder: ignore */
S32 read; /* Flawfinder: ignore */
S32 version;
if (fscanf(in, "LindenResource\nversion %d\n", &version))
{
if (2 == version)
{
// *NOTE: This buffer size is hard coded into scanf() below.
char label[MAX_STRING]; /* Flawfinder: ignore */
char value[MAX_STRING]; /* Flawfinder: ignore */
S32 tokens_read;
while (fgets(buf, 1024, in))
{
label[0] = '\0';
value[0] = '\0';
tokens_read = sscanf( /* Flawfinder: ignore */
buf,
"%254s %254s\n",
label, value);
llinfos << "got: " << label << " = " << value
<< llendl;
if (EOF == tokens_read)
{
fclose(in);
error_message = llformat("corrupt resource file: %s", src_filename.c_str());
args["FILE"] = src_filename;
upload_error(error_message, "CorruptResourceFile", filename, args);
return;
}
if (2 == tokens_read)
{
if (! strcmp("type", label))
{
asset_type = (LLAssetType::EType)(atoi(value));
}
}
else
{
if (! strcmp("_DATA_", label))
{
// below is the data section
break;
}
}
// other values are currently discarded
}
}
else
{
fclose(in);
error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str());
args["FILE"] = src_filename;
upload_error(error_message, "UnknownResourceFileVersion", filename, args);
return;