/
ReadWrite.h
57 lines (51 loc) · 1.18 KB
/
ReadWrite.h
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
#pragma once
#include <string>
#include <fstream>
#include <assert.h>
#include "Resource.h"
using namespace std;
inline string ErrorCodeToStr(const int ecode)
{
string emsg;
switch (ecode)
{
case 060:
emsg = "Cannot locate font file:\n";
break;
case 130:
emsg = "Cannot locate mesh file:\n";
break;
case 110:
emsg = "Cannot locate material definition file:\n";
break;
case 150:
emsg = "Cannot locate texture map file:\n";
break;
case 151:
emsg = "Invalid LoD for texture map file:\n";
break;
case 200:
emsg = "Cannot locate texture file:\n";
break;
default:
emsg = "n/a";
break;
}
return emsg;
}
inline void HandleFatalError(const int ecode, string emsg)
{
wstring wemsg = StrToWstr(emsg);
int msgboxID = MessageBox(
NULL,
(LPCWSTR)(L"The application encountered a fatal error and needs to close.\nError message: "+wemsg).c_str(),
(LPCWSTR)(L"Fatal Error ("+IntToWstr(ecode)+L")").c_str(), MB_ICONERROR | MB_OK
);
exit(EXIT_FAILURE);
}
inline string readFile(const string filename)
{
ifstream sourceFile(filename);
string sourceCode(istreambuf_iterator<char>(sourceFile),(istreambuf_iterator<char>()));
return sourceCode;
}