Пример #1
0
void ResourcesSerializationUtil::saveResource( Filesystem& filesystem, const Resource* savedResource, const FilePath& differentSavePath )
{
   if ( !savedResource )
   {
      return;
   }

   // see if the user doesn't want to save the resource under a different name
   FilePath savedResourcePath;
   if ( !differentSavePath.empty() )
   {
      savedResourcePath = differentSavePath;
   }
   else
   {
      savedResourcePath = savedResource->getFilePath();
   }

   std::string extension = savedResourcePath.extractExtension();
   std::ios_base::openmode accessMode = Resource::getFileAccessMode( extension );
   File* file = filesystem.open( savedResourcePath, std::ios_base::out | accessMode );

   if ( !file )
   {
      return;
   }

   // save the resource
   OutFileStream outStream( file );
   ReflectionSaver saver( outStream );
   saver.save( savedResource );
}
Пример #2
0
void ProjectLeafNode::setEntrySize( const Filesystem& fs )
{
   std::string relativePath = getRelativePath();

   std::size_t fileSize = 0;
   File* file = fs.open( relativePath );
   if ( file )
   {
      fileSize = file->size();
      delete file;
   }
   else
   {
      fileSize = 0;
   }

   char fileSizeStr[ 32 ];
   sprintf_s( fileSizeStr, "%d", fileSize );
   setText( 1, fileSizeStr );
}