-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_configFile.cpp
More file actions
57 lines (43 loc) · 936 Bytes
/
Copy pathfile_configFile.cpp
File metadata and controls
57 lines (43 loc) · 936 Bytes
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
/*AUTHOR:Marian Witek
*The file is free for any usage
*https://infomaks.pl
*/
#include <vector>
#include <iostream>
#include <print>
#include <array>
#include <fstream>
struct Configuration {
bool isFullscreen;
};
std::ifstream in;
std::ofstream out;
void CreateDefaultConfigFile(Configuration* config);
void main()
{
Configuration config;
in.open("file.config", std::ios::in | std::ios::binary);
if (!in.is_open()) {
CreateDefaultConfigFile(&config);
}
else
{
in.read((char*)&config, sizeof(config));
in.close();
}
std::cin.get();
}
void CreateDefaultConfigFile(Configuration* config)
{
config->isFullscreen = false;
//
out.open("file.config", std::ios::out | std::ios::binary);
if (!out.is_open()) {
std::cout << "can't create default configuration file\n";
}
else
{
out.write((char*)config, sizeof(Configuration));
out.close();
}
}