-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGo-CamRecorder.cpp
executable file
·56 lines (47 loc) · 1.08 KB
/
Go-CamRecorder.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
52
53
54
55
56
/**
* @file Go-CamRecorder.cpp
* @ingroup Go-CamRecorder
* @author Dominique Vaufreydaz, personnal project
* @copyright All right reserved.
*/
#include "Go-CamRecorder.h"
// Unique instance of ConfigInfo to read/save from file
ConfigInfo SingleConfig;
/**
* @brief Load values from the ConfigFileName file.
* @return True if ok.
*/
bool ConfigInfo::Load()
{
FILE * fin = fopen( ConfigFileName, "rb" );
if ( fin == nullptr )
{
return false;
}
Omiscid::MemoryBuffer Tmpc(1024);
Omiscid::SimpleString JsonData;
while( fgets( (char*)Tmpc, (int)Tmpc.GetLength(), fin ) )
{
JsonData += (char*)Tmpc;
}
Unserialize(JsonData);
fclose( fin );
return true;
}
/**
* @brief Save values to the ConfigFileName file.
* @return True if ok.
*/
bool ConfigInfo::Save()
{
FILE * fout = fopen( ConfigFileName, "wb" );
if ( fout == nullptr )
{
return false;
}
Omiscid::StructuredMessage::Indented = true;
Omiscid::SimpleString JsonData = Serialize();
fprintf( fout, "%s\n", JsonData.GetStr() );
fclose( fout );
return true;
}