本文整理汇总了C++中LLAPRFile::read方法的典型用法代码示例。如果您正苦于以下问题:C++ LLAPRFile::read方法的具体用法?C++ LLAPRFile::read怎么用?C++ LLAPRFile::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLAPRFile
的用法示例。
在下文中一共展示了LLAPRFile::read方法的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: openAndReadEntries
U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries)
{
U32 num_entries = mHeaderEntriesInfo.mEntries;
mHeaderIDMap.clear();
mTexturesSizeMap.clear();
mFreeList.clear();
mTexturesSizeTotal = 0;
LLAPRFile* aprfile = openHeaderEntriesFile(false, (S32)sizeof(EntriesInfo));
for (U32 idx=0; idx<num_entries; idx++)
{
Entry entry;
S32 bytes_read = aprfile->read((void*)(&entry), (S32)sizeof(Entry));
if (bytes_read < sizeof(Entry))
{
llwarns << "Corrupted header entries, failed at " << idx << " / " << num_entries << llendl;
closeHeaderEntriesFile();
purgeAllTextures(false);
return 0;
}
entries.push_back(entry);
// llinfos << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << llendl;
if (entry.mImageSize < 0)
{
mFreeList.insert(idx);
}
else
{
mHeaderIDMap[entry.mID] = idx;
if (entry.mBodySize > 0)
{
mTexturesSizeMap[entry.mID] = entry.mBodySize;
mTexturesSizeTotal += entry.mBodySize;
}
llassert_always(entry.mImageSize == 0 || entry.mImageSize > entry.mBodySize);
}
}
closeHeaderEntriesFile();
return num_entries;
}
示例4: upload_new_resource
//.........这里部分代码省略.........
llinfos << "Attempting to encode wav as an ogg file" << llendl;
encode_result = encode_vorbis_file(src_filename, filename);
if (LLVORBISENC_NOERR != encode_result)
{
switch(encode_result)
{
case LLVORBISENC_DEST_OPEN_ERR:
error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str());
args["FILE"] = filename;
upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args);
break;
default:
error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str());
args["FILE"] = src_filename;
upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args);
break;
}
return;
}
}
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)
{
示例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: encode_vorbis_file
S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname)
{
#define READ_BUFFER 1024
unsigned char readbuffer[READ_BUFFER*4+44]; /* out of the data segment, not the stack */ /*Flawfinder: ignore*/
ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */
ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
ogg_packet op; /* one raw packet of data for decode */
vorbis_info vi; /* struct that stores all the static vorbis bitstream settings */
vorbis_comment vc; /* struct that stores all the user comments */
vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
vorbis_block vb; /* local working space for packet->PCM decode */
int eos=0;
int result;
U16 num_channels = 0;
U32 sample_rate = 0;
U32 bits_per_sample = 0;
S32 format_error = 0;
std::string error_msg;
if ((format_error = check_for_invalid_wav_formats(in_fname, error_msg)))
{
llwarns << error_msg << ": " << in_fname << llendl;
return(format_error);
}
#if 1
unsigned char wav_header[44]; /*Flawfinder: ignore*/
S32 data_left = 0;
LLAPRFile infile ;
infile.open(in_fname,LL_APR_RB);
if (!infile.getFileHandle())
{
llwarns << "Couldn't open temporary ogg file for writing: " << in_fname
<< llendl;
return(LLVORBISENC_SOURCE_OPEN_ERR);
}
LLAPRFile outfile ;
outfile.open(out_fname,LL_APR_WPB);
if (!outfile.getFileHandle())
{
llwarns << "Couldn't open upload sound file for reading: " << in_fname
<< llendl;
return(LLVORBISENC_DEST_OPEN_ERR);
}
// parse the chunks
U32 chunk_length = 0;
U32 file_pos = 12; // start at the first chunk (usually fmt but not always)
while (infile.eof() != APR_EOF)
{
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];
// llinfos << "chunk found: '" << wav_header[0] << wav_header[1] << wav_header[2] << wav_header[3] << "'" << llendl;
if (!(strncmp((char *)&(wav_header[0]),"fmt ",4)))
{
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];
}
else if (!(strncmp((char *)&(wav_header[0]),"data",4)))
{
infile.seek(APR_SET,file_pos+8);
// leave the file pointer at the beginning of the data chunk data
data_left = chunk_length;
break;
}
file_pos += (chunk_length + 8);
chunk_length = 0;
}
/********** Encode setup ************/
/* choose an encoding mode */
/* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */
vorbis_info_init(&vi);
// always encode to mono
// SL-52913 & SL-53779 determined this quality level to be our 'good
// enough' general-purpose quality level with a nice low bitrate.
//.........这里部分代码省略.........
示例8: postBuild
//.........这里部分代码省略.........
//childSetValidate("loop_out_point", validateLoopOut);
//childSetCommitCallback("hand_pose_combo", onCommitHandPose, this);
//childSetCommitCallback("emote_combo", onCommitEmote, this);
//childSetValue("emote_combo", "[None]");
//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);
示例9: openAndReadEntry
S32 LLTextureCache::openAndReadEntry(const LLUUID& id, Entry& entry, bool create)
{
S32 idx = -1;
id_map_t::iterator iter1 = mHeaderIDMap.find(id);
if (iter1 != mHeaderIDMap.end())
{
idx = iter1->second;
}
if (idx < 0)
{
if (create && !mReadOnly)
{
if (mHeaderEntriesInfo.mEntries < sCacheMaxEntries)
{
// Add an entry to the end of the list
idx = mHeaderEntriesInfo.mEntries++;
}
else if (!mFreeList.empty())
{
idx = *(mFreeList.begin());
mFreeList.erase(mFreeList.begin());
}
else
{
// Look for a still valid entry in the LRU
for (std::set<LLUUID>::iterator iter2 = mLRU.begin(); iter2 != mLRU.end();)
{
std::set<LLUUID>::iterator curiter2 = iter2++;
LLUUID oldid = *curiter2;
// Erase entry from LRU regardless
mLRU.erase(curiter2);
// Look up entry and use it if it is valid
id_map_t::iterator iter3 = mHeaderIDMap.find(oldid);
if (iter3 != mHeaderIDMap.end() && iter3->second >= 0)
{
idx = iter3->second;
mHeaderIDMap.erase(oldid);
mTexturesSizeMap.erase(oldid);
break;
}
}
// if (idx < 0) at this point, we will rebuild the LRU
// and retry if called from setHeaderCacheEntry(),
// otherwise this shouldn't happen and will trigger an error
}
if (idx >= 0)
{
// Set the header index
mHeaderIDMap[id] = idx;
llassert_always(mTexturesSizeMap.erase(id) == 0);
// Initialize the entry (will get written later)
entry.init(id, time(NULL));
// Update Header
writeEntriesHeader();
// Write Entry
S32 offset = sizeof(EntriesInfo) + idx * sizeof(Entry);
LLAPRFile* aprfile = openHeaderEntriesFile(false, offset);
S32 bytes_written = aprfile->write((void*)&entry, (S32)sizeof(Entry));
llassert_always(bytes_written == sizeof(Entry));
mHeaderEntriesMaxWriteIdx = llmax(mHeaderEntriesMaxWriteIdx, idx);
closeHeaderEntriesFile();
}
}
}
else
{
// Remove this entry from the LRU if it exists
mLRU.erase(id);
// Read the entry
S32 offset = sizeof(EntriesInfo) + idx * sizeof(Entry);
LLAPRFile* aprfile = openHeaderEntriesFile(true, offset);
S32 bytes_read = aprfile->read((void*)&entry, (S32)sizeof(Entry));
llassert_always(bytes_read == sizeof(Entry));
llassert_always(entry.mImageSize == 0 || entry.mImageSize == -1 || entry.mImageSize > entry.mBodySize);
closeHeaderEntriesFile();
}
return idx;
}
示例10: fire
void fire(const LLUUID &inv_item)
{
S32 file_size;
LLAPRFile infile;
infile.open(data->filename, LL_APR_RB, LLAPRFile::access_t(), &file_size);
if (infile.getFileHandle())
{
//cmdline_printchat("got file handle @ postinv");
LLVFile file(gVFS, data->assetid, data->type, LLVFile::WRITE);
file.setMaxSize(file_size);
const S32 buf_size = 65536;
U8 copy_buf[buf_size];
while ((file_size = infile.read(copy_buf, buf_size)))
{
file.write(copy_buf, file_size);
}
switch(data->type)
{
case LLAssetType::AT_NOTECARD:
//cmdline_printchat("case notecard @ postinv");
{
*//*LLViewerTextEditor* edit = new LLViewerTextEditor("",LLRect(0,0,0,0),S32_MAX,"");
S32 size = gVFS->getSize(data->assetid, data->type);
U8* buffer = new U8[size];
gVFS->getData(data->assetid, data->type, buffer, 0, size);
edit->setText(LLStringExplicit((char*)buffer));
std::string card;
edit->exportBuffer(card);
cmdline_printchat("Encoded notecard");;
edit->die();
delete buffer;
//buffer = new U8[card.size()];
//size = card.size();
//strcpy((char*)buffer,card.c_str());
file.remove();
LLVFile newfile(gVFS, data->assetid, data->type, LLVFile::APPEND);
newfile.setMaxSize(size);
newfile.write((const U8*)card.c_str(),size);*//*
//FAIL.
std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory");
LLSD body;
body["item_id"] = inv_item;
//cmdline_printchat("posting content as " + data->assetid.asString());
LLHTTPClient::post(agent_url, body,
new JCPostInvUploadResponder(body, data->assetid, data->type,inv_item,data));
}
break;
case LLAssetType::AT_LSL_TEXT:
//cmdline_printchat("case lsltext @ postinv");
{
std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgent");
LLSD body;
body["item_id"] = inv_item;
S32 size = gVFS->getSize(data->assetid, data->type);
U8* buffer = new U8[size];
gVFS->getData(data->assetid, data->type, buffer, 0, size);
std::string script((char*)buffer);
BOOL domono = FALSE;//Phox- this needs to be fixed when the preproc is added = JCLSLPreprocessor::mono_directive(script);
*//*if(script.find("//mono\n") != -1)
{
domono = TRUE;
}else if(script.find("//lsl2\n") != -1)
{
domono = FALSE;
}*//*
delete buffer;
buffer = 0;
body["target"] = (domono == TRUE) ? "mono" : "lsl2";
//cmdline_printchat("posting content as " + data->assetid.asString());
LLHTTPClient::post(url, body, new JCPostInvUploadResponder(body, data->assetid, data->type,inv_item,data));
}
break;
default:
break;
}
示例11: send_inventory
void ImportTracker::send_inventory(LLSD& prim)
{
U32 local_id = prim["LocalID"].asInteger();
if (prim.has("inventory"))
{
std::string assetpre = asset_dir + gDirUtilp->getDirDelimiter();
LLSD inventory = prim["inventory"];
for (LLSD::array_iterator inv = inventory.beginArray(); inv != inventory.endArray(); ++inv)
{
LLSD item = (*inv);
InventoryImportInfo* data = new InventoryImportInfo;
data->localid = local_id;
LLTransactionID tid;
tid.generate();
LLUUID assetid = tid.makeAssetID(gAgent.getSecureSessionID());
data->tid = tid;
data->assetid = assetid;
data->type = LLAssetType::lookup(item["type"].asString());////LLAssetType::EType(U32(item["type"].asInteger()));
data->name = item["name"].asString();
data->description = item["desc"].asString();
if(item.has("item_id"))
{
//cmdline_printchat("item id found");
std::string filename = assetpre + item["item_id"].asString() + "." + item["type"].asString();
//S32 file_size;
//LLAPRFile infile ;
//infile.open(filename, LL_APR_RB, NULL, &file_size);
//apr_file_t* fp = infile.getFileHandle();
//if(fp)
if(LLFile::isfile(filename))
{
//cmdline_printchat("file "+filename+" exists");
data->filename = filename;
//infile.close();
}else
{
//cmdline_printchat("file "+filename+" does not exist");
delete data;
continue;
}
}else
{
//cmdline_printchat("item id not found");
delete data;
continue;
}
data->wear_type = NOT_WEARABLE;
//if(data->type == LLAssetType::AT_LSL_TEXT)
{
data->inv_type = LLInventoryType::defaultForAssetType(data->type);
//printchat("is script");
data->compiled = false;
//
switch(data->type)
{
case LLAssetType::AT_TEXTURE:
case LLAssetType::AT_TEXTURE_TGA:
//cmdline_printchat("case textures");
{
std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory");
S32 file_size;
LLAPRFile infile ;
infile.open(data->filename, LL_APR_RB, NULL, &file_size);
if (infile.getFileHandle())
{
//cmdline_printchat("got file handle");
LLVFile file(gVFS, data->assetid, data->type, LLVFile::WRITE);
file.setMaxSize(file_size);
const S32 buf_size = 65536;
U8 copy_buf[buf_size];
while ((file_size = infile.read(copy_buf, buf_size)))
{
file.write(copy_buf, file_size);
}
LLSD body;
body["folder_id"] = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
body["asset_type"] = LLAssetType::lookup(data->type);
body["inventory_type"] = LLInventoryType::lookup(data->inv_type);
body["name"] = data->name;
body["description"] = data->description;
body["next_owner_mask"] = LLSD::Integer(U32_MAX);
body["group_mask"] = LLSD::Integer(U32_MAX);
body["everyone_mask"] = LLSD::Integer(U32_MAX);
body["expected_upload_cost"] = LLSD::Integer(LLGlobalEconomy::Singleton::getInstance()->getPriceUpload());
//cmdline_printchat("posting "+ data->assetid.asString());
LLHTTPClient::post(url, body, new JCImportInventoryResponder(body, data->assetid, data->type,data));
//error = TRUE;
}
}
break;
case LLAssetType::AT_CLOTHING:
case LLAssetType::AT_BODYPART:
//cmdline_printchat("case cloth/bodypart");
{
S32 file_size;
LLAPRFile infile ;
infile.open(data->filename, LL_APR_RB, NULL, &file_size);
if (infile.getFileHandle())
//.........这里部分代码省略.........
示例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
//.........这里部分代码省略.........
if (LLVORBISENC_NOERR != encode_result)
{
switch(encode_result)
{
case LLVORBISENC_DEST_OPEN_ERR:
error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str());
args["FILE"] = filename;
upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args);
break;
default:
error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str());
args["FILE"] = src_filename;
upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args);
break;
}
return;
}
}
else if(exten == "ogg")
{
asset_type = LLAssetType::AT_SOUND; // tag it as audio
filename = src_filename;
}
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)
{