本文整理汇总了C++中FilePtr类的典型用法代码示例。如果您正苦于以下问题:C++ FilePtr类的具体用法?C++ FilePtr怎么用?C++ FilePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OutputInfo
void Profiling::OutputInfo(FilePtr _pFile)
{
const float fTotal = s_fStopTime - s_fStartTime;
if (0.0f < fTotal)
{
const int sSize = _snprintf_s(s_szBuffer, s_uBufferSize, s_uBufferSize, "calls\n");
_pFile->Write(s_szBuffer, sSize);
TagInfoMap::iterator iPair = s_mTags.begin();
TagInfoMap::iterator iEnd = s_mTags.end();
while (iEnd != iPair)
{
TagInfoRef rTagInfo = iPair->second;
const float fAverage = (0 < rTagInfo.m_uCount) ? rTagInfo.m_fTotal / float(rTagInfo.m_uCount) : 0.0f;
const int sSize = _snprintf_s(s_szBuffer, s_uBufferSize, s_uBufferSize,
"%s : %u calls total=%f(%5.2f%%) min=%f max=%f avg=%f\n",
rTagInfo.m_strName.c_str(),
rTagInfo.m_uCount,
rTagInfo.m_fTotal,
(rTagInfo.m_fTotal / fTotal) * 100.0f,
rTagInfo.m_fShortest,
rTagInfo.m_fLongest,
fAverage);
_pFile->Write(s_szBuffer, sSize);
++iPair;
}
{
const int sSize = _snprintf_s(s_szBuffer, s_uBufferSize, s_uBufferSize, "callstack\n");
_pFile->Write(s_szBuffer, sSize);
OutputInfoCallStack(s_mCallStacks, 0, _pFile);
}
}
}
示例2: CreateMemoryFile
HEFFECT D3DCore_Impl::Effect_Load(const WCHAR *filename, DWORD size)
{
if(m_bSilent) return 0;
DWORD _size;
FilePtr pf;
SampleSource* SSource = NULL;
void *data;
if(m_pADevice)
{
if(size) { data=(void *)filename; _size=size; }
else
{
data=File_Load(filename, &_size);
if(!data) return NULL;
}
pf = CreateMemoryFile(data, _size);
if(pf.get() != NULL) {
SSource = OpenSampleSource( pf.get() );
if(!SSource) {
System_Log(L"[AUDIERE - ERROR] %s - Can't create sound effect", filename);
}
SSource->ref();
}
if(!size) File_Free(data);
return (HEFFECT)SSource;
}
else return 0;
}
示例3: while
NodeList FtpManager::parseDirectoryContentsWindows(std::ostringstream &content)
{
std::stringstream ss;
ss << content.str();
NodeList res = NodeList::create();
std::string line;
while (std::getline(ss, line))
{
QString permissions = "";
QString numberOfLinks = "";
QString user = "";
QString group = "";
QString size = "";
QString date = "";
QString time = "";
QString filename = "";
QString l = QString::fromStdString(line);
QStringList fields = l.split(' ', QString::SplitBehavior::SkipEmptyParts);
date = fields[0];
l = l.replace(l.indexOf(date), date.size(), "");
time = fields[1];
l = l.replace(l.indexOf(time), time.size(), "");
QString word = fields[2];
if (word == "<DIR>")
permissions = "d";
else
size = word;
l = l.replace(l.indexOf(word), word.size(), "");
filename = l.trimmed();
if (filename.toLower() != ".control.db")
{
qDebug() << permissions << ", " << numberOfLinks << ", " << user
<< ", " << group << ", " << size << ", " <<
", " << time << ", " << filename;
if (!permissions.startsWith('d'))
{
FilePtr f = FilePtr::create(filename);
f->setFileData(permissions, user, size.toUInt(),
date, time);
(*res)[filename] = f;
}
else
{
FolderPtr f = FolderPtr::create(filename);
(*res)[filename] = f;
}
}
}
return res;
}
示例4: _SetFile
void CShader::_SetFile( FilePtr pFile )
{
VKE_ASSERT( m_pFile.IsNull(), "File already set. Be sure a shader is properly created." );
m_pFile = pFile;
m_Data.pCode = pFile->GetData();
m_Data.codeSize = pFile->GetDataSize();
m_Data.state = ShaderStates::HIGH_LEVEL_TEXT;
this->m_resourceState |= ResourceStates::LOADED;
}
示例5:
list<MapPtr> Process::restrict_maps_to_file(const FilePtr &file)
{
list<MapPtr> file_maps = file->maps();
list<MapPtr> proc_maps = _maps;
list<MapPtr> result = Map::intersect_lists(file_maps, proc_maps);
if (result.size() == 0) {
warn << _pid << ": empty restriction to file " << file->name() << "\n";
}
return result;
}
示例6: AddFile
i32 CDirectory::AddFile(FilePtr pFile)
{
FileMap::iterator Itr = m_mFiles.find( pFile->GetName() );
if( Itr == m_mFiles.end() )
{
m_mFiles.insert( FileMap::value_type( pFile->GetName(), pFile ) );
return RESULT::OK;
}
return RESULT::FAILED;
}
示例7: load
// --------------------------------------------------------------------------
void Property::load(const FileGroupPtr &db, const BitArray &objMask) {
// Open the chunk specified by "P$" + mChunkName
FilePtr fprop;
string pchn = "P$" + mChunkName;
try {
fprop = db->getFile(pchn);
const DarkDBChunkHeader &hdr = db->getFileHeader(pchn);
// compare the versions, log differences
if (hdr.version_high != mVerMaj || hdr.version_low != mVerMin) {
LOG_ERROR("Property %s version mismatch : %d.%d expected, %d.%d "
"encountered",
pchn.c_str(), mVerMaj, mVerMin, hdr.version_high,
hdr.version_low);
}
} catch (const BasicException &) {
LOG_ERROR("Property::load : Could not find the property chunk %s",
pchn.c_str());
return;
}
// Can't calculate the count of the properties, as they can have any size
// load. Each record has: OID, size (32 bit uint's)
int id = 0xDEADBABE;
while (!fprop->eof()) {
// load the id
fprop->readElem(&id, sizeof(uint32_t));
// if the object is not in the mask, skip the property
if (!objMask[id]) {
LOG_DEBUG("Property::load: skipping object %d, not in bitmap", id);
// prop has length and data - so skip according to that
uint32_t size;
fprop->read(&size, sizeof(uint32_t));
fprop->seek(size, File::FSEEK_CUR);
continue;
}
// Use property storage to load the property
if (mPropertyStorage->readFromFile(fprop, id, true)) {
_addProperty(id);
} else {
LOG_ERROR("There was an error loading property %s for object %d. "
"Property was not loaded",
mName.c_str(), id);
}
}
}
示例8: OpenFile
FilePtr FSMemory::OpenFile(const string& _strPath, const EOpenMode& _eMode)
{
FileMemory::CreateInfo oFMCInfo = { _strPath, _eMode };
FilePtr pResult = new FileMemory;
if (false == pResult->Create(boost::any(&oFMCInfo)))
{
CloseFile(pResult);
pResult = NULL;
}
return pResult;
}
示例9: _CreateFile
FilePtr CFileManager::LoadFile(const SFileCreateDesc& Desc)
{
FilePtr pFile = _CreateFile( Desc );
if( VKE_SUCCEEDED( _LoadFromFile( &pFile ) ) )
{
}
else
{
pFile->Release();
pFile = nullptr;
}
return pFile;
}
示例10:
std::shared_ptr<ShaderProgram> ContentManager::LoadNew(const std::string &name, bool async)
{
FilePtr fp = FileManager::Instance()->OpenFile(name);
if (!fp)
{
LOG("Failed loading '%s': file not found", name.c_str());
return nullptr;
}
int size = fp->GetSize();
char *data = new char[size + 1];
fp->Read(data, size);
fp->Close();
data[size] = 0;
ShaderProgramPtr program = std::make_shared<ShaderProgram>();
ShaderPtr vs = std::make_shared<Shader>(GL_VERTEX_SHADER);
if (!vs->Load(data))
{
LOG("Error loading '%s' vertex shader: %s", name.c_str(), vs->ErrorMessage().c_str());
return nullptr;
}
program->AddShader(vs);
ShaderPtr ps = std::make_shared<Shader>(GL_FRAGMENT_SHADER);
if (!ps->Load(data))
{
LOG("Error loading '%s' fragment shader: %s", name.c_str(), vs->ErrorMessage().c_str());
return nullptr;
}
program->AddShader(ps);
if (!program->Link())
{
LOG("Error loading '%s': link failed", name.c_str());
return nullptr;
}
ContentManager::Instance()->CacheObject(name, program);
LOG("Loaded shader '%s'", name.c_str());
return program;
}
示例11: print
void PrintClassDecl::print (FilePtr const & file, ClassDeclPtr const & class_decl) const
{
// instantiation extern only if dll_api macro is set
bool has_exports = is_inst && is_inst_extern && conf::isOptionSet (conf::opt_dll_api);
if (has_exports)
{
// we know dll_exports macro is set if dll_api macro is set
file->getStream (skind) << "#ifndef " << conf::getOptionValue (conf::opt_dll_exports) << '\n';
}
String str = declToString (class_decl);
str += ';';
printLine (file, skind, getNameLoc (class_decl->getName ()), str);
if (has_exports)
{
file->getStream (skind) << "#endif" << '\n';
}
}
示例12: Create
bool DisplaySurface::Create(const boost::any& _rConfig)
{
CreateInfo* pInfo = boost::any_cast<CreateInfo*>(_rConfig);
FilePtr pFile = NULL;
bool bResult = (NULL != pInfo);
{
pFile = FS::GetRoot()->OpenFile(pInfo->m_strPath, FS::EOpenMode_READBINARY);
bResult = (NULL != pFile);
}
if (false != bResult)
{
int sSize = pFile->Size();
unsigned char* pBuffer = new unsigned char[sSize];
sSize = pFile->Read(pBuffer, sSize);
bResult = SUCCEEDED(D3DXGetImageInfoFromFileInMemory(pBuffer, sSize, &m_oInfo));
if (false != bResult)
{
#pragma message(__FUNCTION__" : for better support some image formats must be converted into supported surface format. For example luminance image should be translated into paletted surface.")
bResult = SUCCEEDED(m_rDisplay.GetDevicePtr()->CreateOffscreenPlainSurface(m_oInfo.Width, m_oInfo.Height, m_oInfo.Format, D3DPOOL_DEFAULT, &m_pSurface, NULL));
}
if (false != bResult)
{
bResult = SUCCEEDED(D3DXLoadSurfaceFromFileInMemory(m_pSurface, NULL, NULL, pBuffer, sSize, NULL, D3DX_FILTER_NONE, 0xff000000, NULL));
}
if (false != bResult)
{
m_uBPP = m_rDisplay.GetFormatBitsPerPixel(m_oInfo.Format);
bResult = (0 != m_uBPP);
}
delete[] pBuffer;
FS::GetRoot()->CloseFile(pFile);
}
return bResult;
}
示例13: print
void PrintObjDecl::print (FilePtr const & file, SectionKind skind, ObjPtr const & obj) const
{
printHashLine (file, skind, getNameLoc (obj->getName ()));
std::ostream & os = file->indent (skind) << declToString (obj);
if (with_init && obj->hasInit ())
{
os << ' ';
obj->getInit ()->print (file, skind);
}
os << ';' << '\n';
}
示例14: loadFileNameFromTag
//------------------------------------------------------
std::string DatabaseService::loadFileNameFromTag(const Opde::FileGroupPtr &db,
const char *tagname) {
FilePtr fdm = db->getFile(tagname);
size_t gft_size = fdm->size();
std::string res;
char *data = NULL;
data = new char[gft_size + 1];
data[0] = 0x0;
data[gft_size] = 0x0;
fdm->read(data, fdm->size()); // TODO: Catch exception
res = std::string(data);
delete[] data;
return res;
}
示例15: Loadfile
bool Lua::Loadfile(const string& _strFileName, LuaStatePtr _pState)
{
FilePtr pFile = FS::GetRoot()->OpenFile(_strFileName, FS::EOpenMode_READTEXT);
bool bResult = (NULL != pFile);
if (false != bResult)
{
int sSize = pFile->Size();
char* pSourceCode = new char[sSize + 1];
sSize = pFile->Read(pSourceCode, sSize);
FS::GetRoot()->CloseFile(pFile);
pSourceCode[sSize] = '\0';
_pState = (NULL == _pState) ? s_pState : _pState;
const int sResult = _pState->DoString(pSourceCode);
bResult = (0 == sResult);
delete[] pSourceCode;
if (false == bResult)
{
OutputError(sResult, _pState);
}
}
return bResult;
}