-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWriteToOutput.cpp
51 lines (48 loc) · 1.6 KB
/
WriteToOutput.cpp
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
#include "resource.h"
void WriteFile()//(BLOCKOBJ m_sectionHeader, BLOCKOBJ m_sectionInclude, BLOCKOBJ m_sectionDataSection, BLOCKOBJ m_sectionTextSection, BLOCKOBJ m_sectionImportSection)
{
string m_szConcatenatedBuffer;
ofstream m_oOutFile;
// Header
for (unsigned int i = 0; i < m_sectionArray[0].m_vszBuffer.size(); i++)
{
m_szConcatenatedBuffer += m_sectionArray[0].m_vszBuffer[i];
m_szConcatenatedBuffer += "\n";
}
// Include
for (unsigned int i = 0; i < m_sectionArray[1].m_vszBuffer.size(); i++)
{
m_szConcatenatedBuffer += m_sectionArray[1].m_vszBuffer[i];
m_szConcatenatedBuffer += "\n";
}
// Data section
for (unsigned int i = 0; i < m_sectionArray[2].m_vszBuffer.size(); i++)
{
m_szConcatenatedBuffer += m_sectionArray[2].m_vszBuffer[i];
m_szConcatenatedBuffer += "\n";
}
// Text Section
for (unsigned int i = 0; i < m_sectionArray[3].m_vszBuffer.size(); i++)
{
m_szConcatenatedBuffer += m_sectionArray[3].m_vszBuffer[i];
m_szConcatenatedBuffer += "\n";
}
// Import section
for (unsigned int i = 0; i < m_sectionArray[4].m_vszBuffer.size(); i++)
{
m_szConcatenatedBuffer += m_sectionArray[4].m_vszBuffer[i];
m_szConcatenatedBuffer += "\n";
}
m_oOutFile.open("Example.txt");
// prevent errors in assembling
if (m_szConcatenatedBuffer[m_szConcatenatedBuffer.length()-3] == ',')
{
m_szConcatenatedBuffer[m_szConcatenatedBuffer.length()-3] = ' ';
}
if (m_szConcatenatedBuffer[m_szConcatenatedBuffer.length()-2] == '\\') // need escape char
{
m_szConcatenatedBuffer[m_szConcatenatedBuffer.length()-2] = ' ';
}
m_oOutFile << m_szConcatenatedBuffer;
m_oOutFile.close();
}