本文整理汇总了C++中FileSystem::CreateFileStream方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::CreateFileStream方法的具体用法?C++ FileSystem::CreateFileStream怎么用?C++ FileSystem::CreateFileStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::CreateFileStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
//--------------------------------------------------------------
//--------------------------------------------------------------
void AppDataStore::Save()
{
std::unique_lock<std::mutex> lock(m_mutex);
if(m_needsSynchonised == true)
{
// Convert to XML
XML::Document doc;
XML::Node* rootNode = doc.allocate_node(rapidxml::node_type::node_element);
doc.append_node(rootNode);
ParamDictionarySerialiser::ToXml(m_dictionary, rootNode);
// Encrypt
std::string strDocToBeEncrypted = XMLUtils::ToString(&doc);
AESEncrypt::Data encryptedData = AESEncrypt::EncryptString(strDocToBeEncrypted, k_privateKey);
// Write to disk
FileSystem* pFileSystem = Application::Get()->GetFileSystem();
FileStreamSPtr pFileStream = pFileSystem->CreateFileStream(StorageLocation::k_saveData, k_filename, FileMode::k_writeBinary);
if(pFileStream != nullptr)
{
pFileStream->Write(reinterpret_cast<const s8*>(encryptedData.m_data.get()), encryptedData.m_size);
pFileStream.reset();
}
m_needsSynchonised = false;
}
}
示例2: RefreshFromFile
//--------------------------------------------------------------
//--------------------------------------------------------------
void AppDataStore::RefreshFromFile()
{
FileSystem* pFileSystem = Application::Get()->GetFileSystem();
if(pFileSystem->DoesFileExist(StorageLocation::k_saveData, k_filename) == true)
{
FileStreamSPtr fileStream = pFileSystem->CreateFileStream(StorageLocation::k_saveData, k_filename, FileMode::k_readBinary);
if (fileStream != nullptr)
{
fileStream->SeekG(0, SeekDir::k_end);
u32 encryptedDataSize = fileStream->TellG();
fileStream->SeekG(0, SeekDir::k_beginning);
std::unique_ptr<s8[]> encryptedData(new s8[encryptedDataSize]);
fileStream->Read(encryptedData.get(), encryptedDataSize);
fileStream.reset();
std::string decrypted = AESEncrypt::DecryptString(reinterpret_cast<const u8*>(encryptedData.get()), encryptedDataSize, k_privateKey);
XMLUPtr xml = XMLUtils::ParseDocument(decrypted);
XML::Node* root = XMLUtils::GetFirstChildElement(xml->GetDocument());
if(nullptr != root)
{
m_dictionary = ParamDictionarySerialiser::FromXml(root);
}
}
}
m_needsSynchonised = false;
}
示例3: ReadChunkTable
//--------------------------------------------------------------
//--------------------------------------------------------------
CSBinaryInputStream::CSBinaryInputStream(StorageLocation in_storageLocation, const std::string& in_filePath)
{
FileSystem* fileSystem = Application::Get()->GetFileSystem();
CS_ASSERT(fileSystem != nullptr, "CSBinaryInputStream missing required system: FileSystem.");
m_fileStream = fileSystem->CreateFileStream(in_storageLocation, in_filePath, FileMode::k_readBinary);
if (m_fileStream != nullptr)
{
u32 numChunkTableEntries;
if (ReadHeader(m_fileStream.get(), in_filePath, m_fileFormatId, m_fileFormatVersion, numChunkTableEntries) == false)
{
m_fileStream.reset();
return;
}
ReadChunkTable(numChunkTableEntries);
m_isValid = true;
}
}