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


C++ LLAPRFile::write方法代码示例

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


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

示例1: writeEntryAndClose

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: 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;
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:59,代码来源:lllfsthread.cpp

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

示例4: 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

示例5: writeEntriesAndClose

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

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

示例7: writeEntryAndClose

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

示例8: encode_vorbis_file


//.........这里部分代码省略.........
	 vorbis_analysis_init(&vd,&vi);
	 vorbis_block_init(&vd,&vb);
	 
	 /* set up our packet->stream encoder */
	 /* pick a random serial number; that way we can more likely build
		chained streams just by concatenation */
	 ogg_stream_init(&os, ll_rand());
	 
	 /* Vorbis streams begin with three headers; the initial header (with
		most of the codec setup parameters) which is mandated by the Ogg
		bitstream spec.  The second header holds any comment fields.  The
		third header holds the bitstream codebook.  We merely need to
		make the headers, then pass them to libvorbis one at a time;
		libvorbis handles the additional Ogg bitstream constraints */
	 
	 {
		 ogg_packet header;
		 ogg_packet header_comm;
		 ogg_packet header_code;
		 
		 vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);
		 ogg_stream_packetin(&os,&header); /* automatically placed in its own
											  page */
		 ogg_stream_packetin(&os,&header_comm);
		 ogg_stream_packetin(&os,&header_code);
		 
		 /* We don't have to write out here, but doing so makes streaming 
		  * much easier, so we do, flushing ALL pages. This ensures the actual
		  * audio data will start on a new page
		  */
		 while(!eos){
			 int result=ogg_stream_flush(&os,&og);
			 if(result==0)break;
			 outfile.write(og.header, og.header_len);
			 outfile.write(og.body, og.body_len);
		 }
		 
	 }
	 
	 
	 while(!eos)
	 {
		 long bytes_per_sample = bits_per_sample/8;

		 long bytes=(long)infile.read(readbuffer,llclamp((S32)(READ_BUFFER*num_channels*bytes_per_sample),0,data_left)); /* stereo hardwired here */
		 
		 if (bytes==0)
		 {
			 /* end of file.  this can be done implicitly in the mainline,
				but it's easier to see here in non-clever fashion.
				Tell the library we're at end of stream so that it can handle
				the last frame and mark end of stream in the output properly */

			 vorbis_analysis_wrote(&vd,0);
//			 eos = 1;
			 
		 }
		 else
		 {
			 long i;
			 long samples;
			 int temp;

			 data_left -= bytes;
             /* data to encode */
			 
开发者ID:1234-,项目名称:SingularityViewer,代码行数:66,代码来源:llvorbisencode.cpp

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


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