-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathBackgroundReader.cpp
More file actions
62 lines (50 loc) · 1.18 KB
/
Copy pathBackgroundReader.cpp
File metadata and controls
62 lines (50 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright © 2014 CCP ehf.
#include "StdAfx.h"
#include "BackgroundReader.h"
#include "BlueMemStream.h"
#include "BlueResFile.h"
BackgroundReader::BackgroundReader( const std::wstring& filename ) :
m_filename( filename )
{
}
BackgroundReader::~BackgroundReader()
{
}
void BackgroundReader::Perform()
{
ResFilePtr resFile;
if( !resFile.CreateInstance() )
{
m_result = Be::Result<std::string>( "Couldn't create ResFile object" );
return;
}
if (!resFile->OpenW( m_filename.c_str(), true ) )
{
m_result = Be::Result<std::string>( "Couldn't open file" );
return;
}
void* data;
size_t dataSize = resFile->GetSize();
if( !resFile->LockData( &data, dataSize ) )
{
m_result = Be::Result<std::string>( "Couldn't read data" );
return;
}
if( !m_contents.CreateInstance() )
{
resFile->UnlockData();
m_result = Be::Result<std::string>( "Couldn't create MemStream object" );
return;
}
m_contents->Write( data, dataSize );
m_contents->Seek( 0, ICcpStream::SO_BEGIN );
resFile->UnlockData();
}
Be::Result<std::string> BackgroundReader::GetResult()
{
return m_result;
}
void BackgroundReader::TakeContents( IBlueStream** contents )
{
*contents = m_contents.Detach();
}