当前位置: 首页>>代码示例>>C++>>正文


C++ LLAPRFile类代码示例

本文整理汇总了C++中LLAPRFile的典型用法代码示例。如果您正苦于以下问题:C++ LLAPRFile类的具体用法?C++ LLAPRFile怎么用?C++ LLAPRFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LLAPRFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: time

void LLTextureCache::writeEntryAndClose(S32 idx, Entry& entry)
{
	if (idx >= 0)
	{
		if (!mReadOnly)
		{
			entry.mTime = time(NULL);
			if(entry.mImageSize < entry.mBodySize)
			{
				// Just say no, due to my messing around to cache discards other than 0 we can end up here
				// after recalling an image from cache at a lower discard than cached. RC
				return;
			}

			llassert_always(entry.mImageSize == 0 || entry.mImageSize == -1 || entry.mImageSize > entry.mBodySize);
			if (entry.mBodySize > 0)
			{
				mTexturesSizeMap[entry.mID] = entry.mBodySize;
			}
// 			llinfos << "Updating TE: " << idx << ": " << id << " Size: " << entry.mBodySize << " Time: " << entry.mTime << llendl;
			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();
		}
	}
}
开发者ID:9skunks,项目名称:imprudence,代码行数:29,代码来源:lltexturecache.cpp

示例2: saveDotFile

BOOL LLStateDiagram::saveDotFile(const std::string& filename)
{
	LLAPRFile outfile ;
	outfile.open(filename, LL_APR_W);
	
	// <FS:ND> Remove LLVolatileAPRPool/apr_file_t and use FILE* instead
	// apr_file_t* dot_file = outfile.getFileHandle() ;
	LLAPRFile::tFiletype* dot_file = outfile.getFileHandle() ;
	// </FS:ND>

	if (!dot_file)
	{
		LL_WARNS() << "LLStateDiagram::saveDotFile() : Couldn't open " << filename << " to save state diagram." << LL_ENDL;
		return FALSE;
	}
	apr_file_printf(dot_file, "digraph StateMachine {\n\tsize=\"100,100\";\n\tfontsize=40;\n\tlabel=\"Finite State Machine\";\n\torientation=landscape\n\tratio=.77\n");
	
	StateMap::iterator state_it;
	for(state_it = mStates.begin(); state_it != mStates.end(); ++state_it)
	{
		apr_file_printf(dot_file, "\t\"%s\" [fontsize=28,shape=box]\n", state_it->first->getName().c_str());
	}
	apr_file_printf(dot_file, "\t\"All States\" [fontsize=30,style=bold,shape=box]\n");

	Transitions::iterator transitions_it;
	for(transitions_it = mDefaultTransitions.begin(); transitions_it != mDefaultTransitions.end(); ++transitions_it)
	{
		apr_file_printf(dot_file, "\t\"All States\" -> \"%s\" [label = \"%s\",fontsize=24];\n", transitions_it->second->getName().c_str(), 
			transitions_it->second->getName().c_str());
	}

	if (mDefaultState)
	{
		apr_file_printf(dot_file, "\t\"All States\" -> \"%s\";\n", mDefaultState->getName().c_str());
	}

	
	for(state_it = mStates.begin(); state_it != mStates.end(); ++state_it)
	{
		LLFSMState *state = state_it->first;

		Transitions::iterator transitions_it;
		for(transitions_it = state_it->second.begin();
			transitions_it != state_it->second.end();
			++transitions_it)
		{
			std::string state_name = state->getName();
			std::string target_name = transitions_it->second->getName();
			std::string transition_name = transitions_it->first->getName();
			apr_file_printf(dot_file, "\t\"%s\" -> \"%s\" [label = \"%s\",fontsize=24];\n", state->getName().c_str(), 
				target_name.c_str(), 
				transition_name.c_str());
		}
	}

	apr_file_printf(dot_file, "}\n");

	return TRUE;
}
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:59,代码来源:llstatemachine.cpp

示例3: importFirstObject

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);
}
开发者ID:Kiera,项目名称:Crow,代码行数:56,代码来源:llviewerobjectbackup.cpp

示例4: 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;
	}
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:54,代码来源:fsdata.cpp

示例5: createListenPls

static std::string createListenPls( const std::string &url )
{
	LLDir *d = gDirUtilp;
	std::string filename = d->getCacheDir() + d->getDirDelimiter() + "listen.pls";
	LLAPRFile file;

	if(file.open(filename, APR_WRITE | APR_CREATE | APR_TRUNCATE) == APR_SUCCESS) {
		std::string playlist = llformat("[playlist]\nNumberOfEntries=1\nFile1=%s\n", url.c_str());
		file.write(playlist.c_str(), playlist.length());
		return filename;
	}

	return "";
}
开发者ID:Xara,项目名称:Luna-Viewer,代码行数:14,代码来源:audioengine.cpp

示例6: llassert_always

void LLTextureCache::writeEntriesAndClose(const std::vector<Entry>& entries)
{
	S32 num_entries = entries.size();
	llassert_always(num_entries == mHeaderEntriesInfo.mEntries);
	
	if (!mReadOnly)
	{
		LLAPRFile* aprfile = openHeaderEntriesFile(false, (S32)sizeof(EntriesInfo));
		for (S32 idx=0; idx<num_entries; idx++)
		{
			S32 bytes_written = aprfile->write((void*)(&entries[idx]), (S32)sizeof(Entry));
			llassert_always(bytes_written == sizeof(Entry));
		}
		mHeaderEntriesMaxWriteIdx = llmax(mHeaderEntriesMaxWriteIdx, num_entries-1);
		closeHeaderEntriesFile();
	}
}
开发者ID:9skunks,项目名称:imprudence,代码行数:17,代码来源:lltexturecache.cpp

示例7: openHeaderEntriesFile

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;
}
开发者ID:9skunks,项目名称:imprudence,代码行数:41,代码来源:lltexturecache.cpp

示例8: save_filename

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
}
开发者ID:impostor,项目名称:SingularityViewer,代码行数:40,代码来源:llpreviewanim.cpp

示例9: time

void LLTextureCache::writeEntryAndClose(S32 idx, Entry& entry)
{
	if (idx >= 0)
	{
		if (!mReadOnly)
		{
			entry.mTime = time(NULL);
			llassert_always(entry.mImageSize == 0 || entry.mImageSize == -1 || entry.mImageSize > entry.mBodySize);
			if (entry.mBodySize > 0)
			{
				mTexturesSizeMap[entry.mID] = entry.mBodySize;
			}
// 			llinfos << "Updating TE: " << idx << ": " << id << " Size: " << entry.mBodySize << " Time: " << entry.mTime << llendl;
			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();
		}
	}
}
开发者ID:ArminW,项目名称:imprudence,代码行数:22,代码来源:lltexturecache.cpp

示例10: 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";
//.........这里部分代码省略.........
开发者ID:1234-,项目名称:SingularityViewer,代码行数:101,代码来源:llvorbisencode.cpp

示例11: 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.
//.........这里部分代码省略.........
开发者ID:1234-,项目名称:SingularityViewer,代码行数:101,代码来源:llvorbisencode.cpp

示例12: loadTranslationTable

//------------------------------------------------------------------------
// LLBVHLoader::loadTranslationTable()
//------------------------------------------------------------------------
ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
{
	mLineNumber = 0;
	mTranslations.clear();
	mConstraints.clear();

	//--------------------------------------------------------------------
	// open file
	//--------------------------------------------------------------------
	std::string path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName);

	LLAPRFile infile ;
	infile.open(path, LL_APR_R);
	apr_file_t *fp = infile.getFileHandle();
	if (!fp)
		return E_ST_NO_XLT_FILE;

	llinfos << "NOTE: Loading translation table: " << fileName << llendl;

	//--------------------------------------------------------------------
	// register file to be closed on function exit
	//--------------------------------------------------------------------
	
	//--------------------------------------------------------------------
	// load header
	//--------------------------------------------------------------------
	if ( ! getLine(fp) )
		return E_ST_EOF;
	if ( strncmp(mLine, "Translations 1.0", 16) )
		return E_ST_NO_XLT_HEADER;

	//--------------------------------------------------------------------
	// load data one line at a time
	//--------------------------------------------------------------------
	BOOL loadingGlobals = FALSE;
	Translation *trans = NULL;
	while ( getLine(fp) )
	{
		//----------------------------------------------------------------
		// check the 1st token on the line to determine if it's empty or a comment
		//----------------------------------------------------------------
		char token[128]; /* Flawfinder: ignore */
		if ( sscanf(mLine, " %127s", token) != 1 )	/* Flawfinder: ignore */
			continue;

		if (token[0] == '#')
			continue;

		//----------------------------------------------------------------
		// check if a [jointName] or [GLOBALS] was specified.
		//----------------------------------------------------------------
		if (token[0] == '[')
		{
			char name[128]; /* Flawfinder: ignore */
			if ( sscanf(mLine, " [%127[^]]", name) != 1 )
				return E_ST_NO_XLT_NAME;

			if (strcmp(name, "GLOBALS")==0)
			{
				loadingGlobals = TRUE;
				continue;
			}
			else
			{
				loadingGlobals = FALSE;
				Translation &newTrans = mTranslations[ name ];
				trans = &newTrans;
				continue;
			}
		}

		//----------------------------------------------------------------
		// check for optional emote 
		//----------------------------------------------------------------
		if (loadingGlobals && LLStringUtil::compareInsensitive(token, "emote")==0)
		{
			char emote_str[1024];	/* Flawfinder: ignore */
			if ( sscanf(mLine, " %*s = %1023s", emote_str) != 1 )	/* Flawfinder: ignore */
				return E_ST_NO_XLT_EMOTE;

			mEmoteName.assign( emote_str );
//			llinfos << "NOTE: Emote: " << mEmoteName.c_str() << llendl;
			continue;
		}


		//----------------------------------------------------------------
		// check for global priority setting
		//----------------------------------------------------------------
		if (loadingGlobals && LLStringUtil::compareInsensitive(token, "priority")==0)
		{
			S32 priority;
			if ( sscanf(mLine, " %*s = %d", &priority) != 1 )
				return E_ST_NO_XLT_PRIORITY;

			mPriority = priority;
//			llinfos << "NOTE: Priority: " << mPriority << llendl;
//.........这里部分代码省略.........
开发者ID:HyangZhao,项目名称:NaCl-main,代码行数:101,代码来源:llbvhloader.cpp

示例13: upload_new_resource


//.........这里部分代码省略.........
							 }
                         }	 	
                         fclose(out);	 	
                 }	 	
                 else	 	
                 {	 	
                         fclose(in);	 	
                         error_message = llformat( "Unable to create output file: %s", filename.c_str());
						 args["FILE"] = filename;
						 upload_error(error_message, "UnableToCreateOutputFile", filename, args);
                         return;
                 }	 	

                 fclose(in);	 	
         }	 	
         else	 	
         {	 	
                 llinfos << "Couldn't open .lin file " << src_filename << llendl;	 	
         }	 	
	}
	else if(exten == "ogg")
	{
		asset_type = LLAssetType::AT_SOUND;  // tag it as audio
		filename = src_filename;
	}
	else if (exten == "bvh")
	{
		// <edit> THE FUCK WE DON'T
		//error_message = llformat("We do not currently support bulk upload of animation files\n");
		//upload_error(error_message, "DoNotSupportBulkAnimationUpload", filename, args);
		//return;
		asset_type = LLAssetType::AT_ANIMATION;
		S32 file_size;
		LLAPRFile fp;
		
		if(!fp.open(src_filename, LL_APR_RB, LLAPRFile::local, &file_size))
		{
			args["ERROR_MESSAGE"] = llformat("Couldn't read file %s\n", src_filename.c_str());
			LLNotifications::instance().add("ErrorMessage", args);
			return;
		}
		char* file_buffer = new char[file_size + 1];
		if(!fp.read(file_buffer, file_size))
		{
			fp.close();
			delete[] file_buffer;
			args["ERROR_MESSAGE"] = llformat("Couldn't read file %s\n", src_filename.c_str());
			LLNotifications::instance().add("ErrorMessage", args);
			return;
		}
		  ELoadStatus load_status = E_ST_OK;
			S32 line_number = 0; 
			 LLBVHLoader* loaderp = new LLBVHLoader(file_buffer, load_status, line_number);
			///  LLBVHLoader* loaderp = new LLBVHLoader(file_buffer);
		if(!loaderp->isInitialized())
		{
			fp.close();
			delete[] file_buffer;
			args["ERROR_MESSAGE"] = llformat("Couldn't convert file %s to internal animation format\n", src_filename.c_str());
			LLNotifications::instance().add("ErrorMessage", args);
			return;
		}
		S32 buffer_size = loaderp->getOutputSize();
		U8* buffer = new U8[buffer_size];
		LLDataPackerBinaryBuffer dp(buffer, buffer_size);
		loaderp->serialize(dp);
开发者ID:mightymarc,项目名称:cfb,代码行数:67,代码来源:llviewermenufile.cpp

示例14: llassert

bool LLLFSThread::Request::processRequest()
{
	bool complete = false;
	if (mOperation ==  FILE_READ)
	{
		llassert(mOffset >= 0);
		LLAPRFile infile ; // auto-closes
		infile.open(mFileName, LL_APR_RB, mThread->getLocalAPRFilePool());
		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;
// 		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 ; // auto-closes
		outfile.open(mFileName, flags, mThread->getLocalAPRFilePool());
		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
	{
		llerrs << "LLLFSThread::unknown operation: " << (S32)mOperation << llendl;
	}
	return complete;
}
开发者ID:OS-Development,项目名称:VW.Kirsten,代码行数:57,代码来源:lllfsthread.cpp

示例15: switch

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())
//.........这里部分代码省略.........
开发者ID:IamusNavarathna,项目名称:SingularityViewer,代码行数:101,代码来源:importtracker.cpp


注:本文中的LLAPRFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。