本文整理汇总了C++中PathString::ConstPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ PathString::ConstPtr方法的具体用法?C++ PathString::ConstPtr怎么用?C++ PathString::ConstPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathString
的用法示例。
在下文中一共展示了PathString::ConstPtr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
Bool FileSystem::Load( const PathString& fileName, void *& buffer, SizeT& size )
{
FILE * pFile;
if ( fopen_s( &pFile, fileName.ConstPtr(), "rb" ) )
{
return false;
}
fseek( pFile , 0 , SEEK_END );
size = ftell( pFile );
if ( size == 0 )
{
fclose( pFile );
return true;
}
rewind( pFile );
buffer = UnknownAllocator::Allocate( size );
if ( fread( buffer, 1, size, pFile ) != size )
{
UnknownAllocator::Deallocate( buffer );
size = 0;
fclose( pFile );
return false;
}
fclose(pFile);
return true;
}
示例2: Exists
Bool FileSystem::Exists( const PathString& fileName )
{
HANDLE hFile = CreateFile( fileName.ConstPtr(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if ( hFile == INVALID_HANDLE_VALUE )
{
return false;
}
CloseHandle( hFile );
return true;
}
示例3: Save
Bool FileSystem::Save( const PathString& fileName, const void * buffer, SizeT size )
{
Char dir[ 256 ];
Char * fileStart;
if ( GetFullPathName( fileName.ConstPtr(), 256, dir, &fileStart ) == 0 )
{
return false;
}
*( fileStart - 1 ) = 0;
if ( ! RecursiveCreateDirectory( dir ) )
{
return false;
}
FILE * pFile;
if ( fopen_s( &pFile, fileName.ConstPtr(), "wb" ) )
{
return false;
}
if ( size == 0 )
{
fclose( pFile );
return true;
}
if ( fwrite( buffer, 1, size, pFile ) != size )
{
fclose( pFile );
return false;
}
fclose(pFile);
return true;
}
示例4: Add
void ResourceManager::Add( const Char * name, Resource * res )
{
PathString path;
FileSystem::BuildPathName( name, path, FileSystem::PT_CACHE );
ResourceRequest req;
req.m_res = res;
StringUtils::StrCpy( req.m_path, 256, path.ConstPtr() );
if ( !res->IsPending() )
{
res->m_state |= Resource::PENDING;
pendingResources.PushBack( req );
}
resourceTable.Insert( res->GetId(), res );
}
示例5: LoadProgramFromBinaries
void ProgramCache::LoadProgramFromBinaries( Program& program )
{
PathString binFileName = m_cachePath;
binFileName += "/";
binFileName += program.m_name;
binFileName += ".bin";
if ( FileSystem::Exists( binFileName ) )
{
PathString searchStr = m_dataPath;
searchStr += "/";
searchStr += program.m_name;
searchStr += ".*";
Array< PathString > shaderFileNames;
FileSystem::Find( searchStr.ConstPtr(), shaderFileNames );
U64 binLastWriteTime = FileSystem::GetLastWriteTime( binFileName );
Bool binIsUpToDate = true;
Array< PathString >::ConstIterator it = shaderFileNames.Begin();
Array< PathString >::ConstIterator end = shaderFileNames.End();
for ( ; it != end; ++it )
{
const PathString& shaderFileName = *it;
if ( binLastWriteTime < FileSystem::GetLastWriteTime( shaderFileName ) )
{
binIsUpToDate = false;
break;
}
}
if ( binIsUpToDate )
{
SizeT size;
void * buffer;
if ( FileSystem::Load( binFileName, buffer, size ) )
{
program.m_handle = RenderDevice::CreateProgramBinary( buffer, size );
UnknownAllocator::Deallocate( buffer );
}
}
}
}
示例6: GetLastWriteTime
U64 FileSystem::GetLastWriteTime( const PathString& fileName )
{
HANDLE hFile = CreateFile( fileName.ConstPtr(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if ( hFile == INVALID_HANDLE_VALUE )
{
return 0;
}
FILETIME ftCreate, ftAccess, ftWrite;
if ( !GetFileTime( hFile, &ftCreate, &ftAccess, &ftWrite ) )
{
CloseHandle(hFile);
return 0;
}
CloseHandle(hFile);
ULARGE_INTEGER tmp;
tmp.LowPart = ftWrite.dwLowDateTime;
tmp.HighPart = ftWrite.dwHighDateTime;
return tmp.QuadPart;
}
示例7: BuildCache
void ProgramCache::BuildCache()
{
LoadSamplerList();
PathString searchStr = m_dataPath;
searchStr += "/*";
Array< PathString > shaderFileNames;
FileSystem::Find( searchStr.ConstPtr(), shaderFileNames, false );
// Collect infos
Array< PathString >::Iterator sIt = shaderFileNames.Begin();
Array< PathString >::Iterator sEnd = shaderFileNames.End();
for ( ; sIt != sEnd; ++sIt )
{
PathString& name = *sIt;
CARBON_ASSERT( name.Size() > 3 );
const Char * ext = name.End() - 3;
U32 typeMask = 0;
if ( StringUtils::StrCmp( ext, ".vs" ) == 0 )
{
typeMask |= STB_VERTEX_SHADER;
}
else if ( StringUtils::StrCmp( ext, ".fs" ) == 0 )
{
typeMask |= STB_FRAGMENT_SHADER;
}
else if ( StringUtils::StrCmp( ext, ".gs" ) == 0 )
{
typeMask |= STB_GEOMETRY_SHADER;
}
else
{
CARBON_ASSERT( !"shader extension is not managed" );
continue;
}
name.Resize( ext - name.Begin() );
*(name.End()) = 0;
U32 id = CreateId( name.ConstPtr() );
ProgramArray::Iterator program = Find( id );
if ( program == m_programs.End() )
{
m_programs.PushBack( Program( id, typeMask, name.ConstPtr() ) );
program = m_programs.End() - 1;
}
program->m_type |= typeMask;
}
ProgramArray::Iterator pIt = m_programs.Begin();
ProgramArray::Iterator pEnd = m_programs.End();
for ( ; pIt != pEnd; ++pIt )
{
Program& program = *pIt;
LoadProgram( program );
}
LoadProgramSets();
}