diff options
author | Stef Walter <stef@thewalter.net> | 2003-09-17 19:07:23 +0000 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2003-09-17 19:07:23 +0000 |
commit | 3f95d417d9e623ac0c74df8ef11d7a01846392dd (patch) | |
tree | 45ec73f2dc07eafd7f41a6f62a8cdfbaa279469f /NSCmpts/BackupData.cpp |
Diffstat (limited to 'NSCmpts/BackupData.cpp')
-rw-r--r-- | NSCmpts/BackupData.cpp | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/NSCmpts/BackupData.cpp b/NSCmpts/BackupData.cpp new file mode 100644 index 0000000..5459f2a --- /dev/null +++ b/NSCmpts/BackupData.cpp @@ -0,0 +1,105 @@ +// BackupData.cpp: implementation of the CBackupData class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "BackupData.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +UINT CBackupData::m_nExtensions = 0; +UINT CBackupData::m_nSources = 0; + + +UINT CBackupData::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 CBackupData::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 CBackupData::LoadSources(file_array& aSources, 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) + { + aSources.push_back(sPath); + + // Format Key Name + sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt++); + } + + return m_nSources = --nCnt; + +} + +UINT CBackupData::SaveSources(const file_array& aSources, CPropertyBag& settings) +{ + UINT nCnt = 0; // Number of URLs from Registry + string sKeyName; + + file_array::const_iterator iter = aSources.begin(); + for(; iter != aSources.end(); iter++) + { + sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt++); + settings.WriteString(sKeyName, *iter); + } + + UINT nRet = nCnt - 1; + + for(; nCnt < m_nSources; nCnt++) + { + // Format Registry Key + sKeyName.format(NS_BACKUP_REG_SOURCE, nCnt); + settings.DeleteProperty(sKeyName); + } + + return nRet; +} |