-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelper.h
38 lines (27 loc) · 853 Bytes
/
Helper.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
#ifndef HELPER_H
#define HELPER_H
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
class Helper {
public:
static string GetFileContents(const char* fileName) {
ifstream file (fileName, ios::in|ios::binary|ios::ate);
const int size = file.tellg();
if(size <= 0) {
return string();
}
char memblock[size];
file.seekg(0, ios::beg);
file.read(memblock, size);
file.close();
std::string fileString(memblock, size);
return fileString;
}
static bool FileExists(const char* fileName) {
ifstream file(fileName);
return file ? true : false;
}
};
#endif /* HELPER_H */