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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// EncryptData.cpp: implementation of the CEncryptData class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "EncryptData.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
UINT CEncryptData::m_nExtensions = 0;
UINT CEncryptData::m_nPaths = 0;
UINT CEncryptData::LoadExtensions(string_array& asExt, const CPropertyBag& settings)
{
int nCnt = 0; // Number of URLs from Registry
string sExt;
string sKeyName;
// Format Key Name
sKeyName.format(NS_BACKUP_REG_EXT, nCnt++);
while((sExt = settings.GetString(sKeyName, NS_NO_KEY)) != NS_NO_KEY)
{
asExt.push_back(sExt);
sKeyName.format(NS_BACKUP_REG_EXT, nCnt++);
}
m_nExtensions = max(m_nExtensions, --nCnt);
return nCnt;
}
UINT CEncryptData::SaveExtensions(const string_array& asExt, CPropertyBag& settings)
{
UINT nCnt = 0; // Number of URLs from Registry
string sKeyName = _T("");
string_array::const_iterator iter = asExt.begin();
for(; iter != asExt.end(); iter++)
{
sKeyName.format(NS_BACKUP_REG_EXT, nCnt++);
settings.WriteString(sKeyName, *iter);
}
UINT nRet = nCnt - 1;
for(; nCnt < m_nExtensions; nCnt++)
{
// Format Registry Key
sKeyName.format(NS_BACKUP_REG_EXT, nCnt);
settings.DeleteProperty(sKeyName);
}
m_nExtensions = 0;
return nRet;
}
UINT CEncryptData::LoadPaths(file_array& aPaths, const CPropertyBag& settings)
{
int nCnt = 0;
string sPath;
string sKeyName;
// Format Key Name
sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt++);
// Add URLs to List Box
while((sPath = settings.GetString(sKeyName, NS_NO_KEY)) != NS_NO_KEY)
{
aPaths.push_back(sPath);
// Format Key Name
sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt++);
}
return m_nPaths = --nCnt;
}
UINT CEncryptData::SavePaths(const file_array& aPaths, CPropertyBag& settings)
{
UINT nCnt = 0; // Number of URLs from Registry
string sKeyName;
file_array::const_iterator iter = aPaths.begin();
for(; iter != aPaths.end(); iter++)
{
sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt++);
settings.WriteString(sKeyName, *iter);
}
UINT nRet = nCnt - 1;
for(; nCnt < m_nPaths; nCnt++)
{
// Format Registry Key
sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt);
settings.DeleteProperty(sKeyName);
}
return nRet;
}
|