本文整理汇总了C++中Status::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ Status::Read方法的具体用法?C++ Status::Read怎么用?C++ Status::Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Status
的用法示例。
在下文中一共展示了Status::Read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Size
std::string DetailsColumn::Size( const Helium::FilePath& path )
{
Status status;
status.Read( path.Get().c_str() );
int64_t size = status.m_Size;
std::stringstream printSize;
if ( size == 0 )
{
printSize << "0 KB";
}
else if ( size <= 1024 )
{
printSize << "1 KB";
}
else
{
size = size / 1024;
printSize << size << " KB";
}
return printSize.str().c_str();
}
示例2: Initialize
/// Initialize this cache.
///
/// This will verify the existence of the given files and prepare for cache loading. Note that no file loading is
/// performed at this time.
///
/// Once initialization is performed, the table of contents must be loaded using BeginLoadToc().
///
/// @param[in] name Name identifying this cache.
/// @param[in] platform Cache platform identifier.
/// @param[in] pTocFileName FilePath name of the table of contents file.
/// @param[in] pCacheFileName FilePath name of the cache file.
///
/// @return True if initialization was successful, false if not.
///
/// @see Shutdown(), BeginLoadToc()
bool Cache::Initialize( Name name, EPlatform platform, const tchar_t* pTocFileName, const tchar_t* pCacheFileName )
{
HELIUM_ASSERT( !name.IsEmpty() );
HELIUM_ASSERT( static_cast< size_t >( platform ) < static_cast< size_t >( PLATFORM_MAX ) );
HELIUM_ASSERT( pTocFileName );
HELIUM_ASSERT( pCacheFileName );
Shutdown();
m_name = name;
m_platform = platform;
Status status;
status.Read( pTocFileName );
int64_t tocSize64 = status.m_Size;
if( tocSize64 != -1 && static_cast< uint64_t >( tocSize64 ) >= UINT32_MAX )
{
HELIUM_TRACE(
TraceLevels::Error,
TXT( "Cache::Initialize(): TOC file \"%s\" exceeds the maximum allowed size for TOC files (2 GB).\n" ),
pTocFileName );
return false;
}
m_tocFileName = pTocFileName;
m_cacheFileName = pCacheFileName;
m_tocSize = static_cast< uint32_t >( tocSize64 );
HELIUM_ASSERT( !m_pEntryPool );
m_pEntryPool = new ObjectPool< Entry >( ENTRY_POOL_BLOCK_SIZE );
HELIUM_ASSERT( m_pEntryPool );
return true;
}
示例3: TickDeserialize
//.........这里部分代码省略.........
AsyncLoader& rAsyncLoader = AsyncLoader::GetStaticInstance();
FilePath object_file_path = m_packageDirPath + *rObjectData.objectPath.GetName() + TXT( "." ) + Persist::ArchiveExtensions[ Persist::ArchiveTypes::Json ];
bool load_properties_from_file = true;
size_t object_file_size = 0;
if ( !IsValid( pRequest->asyncFileLoadId ) )
{
if (!object_file_path.IsFile())
{
if (pType->GetMetaClass()->IsType( Reflect::GetMetaClass< Resource >() ))
{
HELIUM_TRACE(
TraceLevels::Info,
TXT( "LoosePackageLoader::TickDeserialize(): No object file found for resource \"%s\". Expected file location: \"%s\". This is normal for newly added resources.\n" ),
*rObjectData.objectPath.ToString(),
*object_file_path);
// We will allow continuing to load using all default properties. This behavior is to support dropping resources into the
// data property and autogenerating objects from them.
load_properties_from_file = false;
}
else
{
HELIUM_TRACE(
TraceLevels::Warning,
TXT( "LoosePackageLoader::TickDeserialize(): No object file found for object \"%s\". Expected file location: \"%s\"\n" ),
*rObjectData.objectPath.ToString(),
*object_file_path);
}
}
else
{
Status status;
status.Read( object_file_path.Get().c_str() );
int64_t i64_object_file_size = status.m_Size;
if( i64_object_file_size == -1 )
{
HELIUM_TRACE(
TraceLevels::Warning,
TXT( "LoosePackageLoader::TickDeserialize(): Could not get file size for object file of object \"%s\". Expected file location: \"%s\"\n" ),
*rObjectData.objectPath.ToString(),
*object_file_path );
}
else if( i64_object_file_size == 0 )
{
HELIUM_TRACE(
TraceLevels::Warning,
TXT( "LoosePackageLoader::TickDeserialize(): Object file \"%s\" for objct \"%s\" is empty.\n" ),
*object_file_path,
*rObjectData.objectPath.ToString() );
}
else if( static_cast< uint64_t >( i64_object_file_size ) > static_cast< uint64_t >( ~static_cast< size_t >( 0 ) ) )
{
HELIUM_TRACE(
TraceLevels::Error,
( TXT( "LoosePackageLoader::TickDeserialize(): Object file \"%s\" exceeds the maximum size supported by " )
TXT( "the current platform (file size: %" ) PRIu64 TXT( " bytes; max supported: %" ) PRIuSZ
TXT( " bytes).\n" ) ),
object_file_path.c_str(),
static_cast< uint64_t >( i64_object_file_size ),
~static_cast< size_t >( 0 ) );
}
else
{
object_file_size = static_cast< size_t >(i64_object_file_size);
示例4: CacheEntry
/// Add or update an entry in the cache.
///
/// @param[in] path GameObject path.
/// @param[in] subDataIndex Sub-data index associated with the cached data.
/// @param[in] pData Data to cache.
/// @param[in] timestamp Timestamp value to associate with the entry in the cache.
/// @param[in] size Number of bytes to cache.
///
/// @return True if the cache was updated successfully, false if not.
bool Cache::CacheEntry(
GameObjectPath path,
uint32_t subDataIndex,
const void* pData,
int64_t timestamp,
uint32_t size )
{
HELIUM_ASSERT( pData || size == 0 );
Status status;
status.Read( m_cacheFileName.GetData() );
int64_t cacheFileSize = status.m_Size;
uint64_t entryOffset = ( cacheFileSize == -1 ? 0 : static_cast< uint64_t >( cacheFileSize ) );
HELIUM_ASSERT( m_pEntryPool );
Entry* pEntryUpdate = m_pEntryPool->Allocate();
HELIUM_ASSERT( pEntryUpdate );
pEntryUpdate->offset = entryOffset;
pEntryUpdate->timestamp = timestamp;
pEntryUpdate->path = path;
pEntryUpdate->subDataIndex = subDataIndex;
pEntryUpdate->size = size;
uint64_t originalOffset = 0;
int64_t originalTimestamp = 0;
uint32_t originalSize = 0;
EntryKey key;
key.path = path;
key.subDataIndex = subDataIndex;
EntryMapType::Accessor entryAccessor;
bool bNewEntry = m_entryMap.Insert( entryAccessor, KeyValue< EntryKey, Entry* >( key, pEntryUpdate ) );
if( bNewEntry )
{
HELIUM_TRACE( TraceLevels::Info, TXT( "Cache: Adding \"%s\" to cache \"%s\".\n" ), *path.ToString(), *m_cacheFileName );
m_entries.Push( pEntryUpdate );
}
else
{
HELIUM_TRACE( TraceLevels::Info, TXT( "Cache: Updating \"%s\" in cache \"%s\".\n" ), *path.ToString(), *m_cacheFileName );
m_pEntryPool->Release( pEntryUpdate );
pEntryUpdate = entryAccessor->Second();
HELIUM_ASSERT( pEntryUpdate );
originalOffset = pEntryUpdate->offset;
originalTimestamp = pEntryUpdate->timestamp;
originalSize = pEntryUpdate->size;
if( originalSize < size )
{
pEntryUpdate->offset = entryOffset;
}
else
{
entryOffset = originalOffset;
}
pEntryUpdate->timestamp = timestamp;
pEntryUpdate->size = size;
}
AsyncLoader& rLoader = AsyncLoader::GetStaticInstance();
rLoader.Lock();
bool bCacheSuccess = true;
FileStream* pCacheStream = FileStream::OpenFileStream( m_cacheFileName, FileStream::MODE_WRITE, false );
if( !pCacheStream )
{
HELIUM_TRACE( TraceLevels::Error, TXT( "Cache: Failed to open cache \"%s\" for writing.\n" ), *m_cacheFileName );
bCacheSuccess = false;
}
else
{
HELIUM_TRACE(
TraceLevels::Info,
TXT( "Cache: Caching \"%s\" to \"%s\" (%" ) TPRIu32 TXT( " bytes @ offset %" ) TPRIu64 TXT( ").\n" ),
*path.ToString(),
*m_cacheFileName,
size,
entryOffset );
uint64_t seekOffset = static_cast< uint64_t >( pCacheStream->Seek(
static_cast< int64_t >( entryOffset ),
SeekOrigins::SEEK_ORIGIN_BEGIN ) );
//.........这里部分代码省略.........
示例5: CacheObject
/// @copydoc AssetLoader::CacheObject()
bool LooseAssetLoader::CacheObject( Asset* pAsset, bool bEvictPlatformPreprocessedResourceData )
{
HELIUM_ASSERT( pAsset );
HELIUM_TRACE(
TraceLevels::Info,
TXT( "LooseAssetLoader::CacheObject(): Caching asset %s.\n" ), *pAsset->GetPath().ToString() );
// Don't cache broken objects or packages.
if( pAsset->GetAnyFlagSet( Asset::FLAG_BROKEN ) || pAsset->IsPackage() )
{
return false;
}
// Make sure we have an object preprocessor instance with which to cache the object.
AssetPreprocessor* pAssetPreprocessor = AssetPreprocessor::GetStaticInstance();
if( !pAssetPreprocessor )
{
HELIUM_TRACE(
TraceLevels::Warning,
TXT( "LooseAssetLoader::CacheObject(): Missing AssetPreprocessor to use for caching.\n" ) );
return false;
}
// User configuration objects should not be cached.
AssetPath objectPath = pAsset->GetPath();
Config& rConfig = Config::GetStaticInstance();
// Only cache the files we care about
if ( rConfig.IsAssetPathInUserConfigPackage(objectPath) )
{
return false;
}
int64_t objectTimestamp = pAsset->GetAssetFileTimeStamp();
if( !pAsset->IsDefaultTemplate() )
{
Resource* pResource = Reflect::SafeCast< Resource >( pAsset );
if( pResource )
{
AssetPath baseResourcePath = pResource->GetPath();
HELIUM_ASSERT( !baseResourcePath.IsPackage() );
for( ; ; )
{
AssetPath parentPath = baseResourcePath.GetParent();
if( parentPath.IsEmpty() || parentPath.IsPackage() )
{
break;
}
baseResourcePath = parentPath;
}
FilePath sourceFilePath;
if ( !FileLocations::GetDataDirectory( sourceFilePath ) )
{
HELIUM_TRACE(
TraceLevels::Warning,
TXT( "LooseAssetLoader::CacheObject(): Could not obtain data directory.\n" ) );
return false;
}
sourceFilePath += baseResourcePath.ToFilePathString().GetData();
Status stat;
stat.Read( sourceFilePath.Get().c_str() );
int64_t sourceFileTimestamp = stat.m_ModifiedTime;
if( sourceFileTimestamp > objectTimestamp )
{
objectTimestamp = sourceFileTimestamp;
}
}
}
// Cache the object.
bool bSuccess = pAssetPreprocessor->CacheObject(
pAsset,
objectTimestamp,
bEvictPlatformPreprocessedResourceData );
if( !bSuccess )
{
HELIUM_TRACE(
TraceLevels::Error,
TXT( "LooseAssetLoader: Failed to cache object \"%s\".\n" ),
*objectPath.ToString() );
}
return bSuccess;
}