summaryrefslogtreecommitdiff
path: root/shared/shadow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'shared/shadow.cpp')
-rw-r--r--shared/shadow.cpp57
1 files changed, 24 insertions, 33 deletions
diff --git a/shared/shadow.cpp b/shared/shadow.cpp
index 5827badd..948050b6 100644
--- a/shared/shadow.cpp
+++ b/shared/shadow.cpp
@@ -6,30 +6,27 @@
//
#include "shadow.h"
#include <wx/msw/wrapwin.h> //includes "windows.h"
-#include "system_constants.h"
#include "i18n.h"
#include "dll_loader.h"
#include <stdexcept>
#include "assert_static.h"
#include "build_info.h"
#include "ShadowCopy\shadow.h"
-#include "string_conv.h"
#include "Loki/ScopeGuard.h"
using shadow::ShadowCopy;
-using shadow::WaitingForShadow;
-using zen::FileError;
+using namespace zen;
namespace
{
bool newerThanXP()
{
- OSVERSIONINFO osvi;
+ OSVERSIONINFO osvi = {};
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- if (GetVersionEx(&osvi))
+ if (::GetVersionEx(&osvi))
return osvi.dwMajorVersion > 5 ||
(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion > 1) ;
//XP has majorVersion == 5, minorVersion == 1
@@ -60,7 +57,8 @@ bool runningWOW64() //test if process is running under WOW64 (reference http://m
}
-const std::wstring& getShadowDllName()
+inline
+std::wstring getShadowDllName()
{
/*
distinguish a bunch of VSS builds: we use XP and Server 2003 implementations...
@@ -69,24 +67,17 @@ const std::wstring& getShadowDllName()
assert_static(util::is32BitBuild || util::is64BitBuild);
- static const std::wstring filename(
- newerThanXP() ?
- (util::is64BitBuild ?
- L"Shadow_Server2003_x64.dll" :
- L"Shadow_Server2003_Win32.dll") :
+ return newerThanXP() ?
+ (util::is64BitBuild ?
+ L"Shadow_Server2003_x64.dll" :
+ L"Shadow_Server2003_Win32.dll") :
- (util::is64BitBuild ?
- L"Shadow_XP_x64.dll" :
- L"Shadow_XP_Win32.dll"));
-
-
- return filename;
+ (util::is64BitBuild ?
+ L"Shadow_XP_x64.dll" :
+ L"Shadow_XP_Win32.dll");
}
}
-
-//#############################################################################################################
-ShadowCopy::ShadowCopy(WaitingForShadow* callback) : callback_(callback) {}
//#############################################################################################################
@@ -107,14 +98,14 @@ public:
//check if shadow copy dll was loaded correctly
if (createShadowCopy == NULL ||
releaseShadowCopy == NULL)
- throw FileError(wxString(_("Error starting Volume Shadow Copy Service!")) + wxT("\n") +
- _("Could not load a required DLL:") + wxT(" \"") + getShadowDllName().c_str() + wxT("\""));
+ throw FileError(_("Error starting Volume Shadow Copy Service!") + "\n" +
+ _("Could not load a required DLL:") + " \"" + getShadowDllName() + "\"");
//VSS does not support running under WOW64 except for Windows XP and Windows Server 2003
//(Reference: http://msdn.microsoft.com/en-us/library/aa384627(VS.85).aspx)
static const bool wow64Active = runningWOW64();
if (wow64Active)
- throw FileError(wxString(_("Error starting Volume Shadow Copy Service!")) + wxT("\n") +
+ throw FileError(_("Error starting Volume Shadow Copy Service!") + "\n" +
_("Making shadow copies on WOW64 is not supported. Please use FreeFileSync 64-bit version."));
//---------------------------------------------------------------------------------------------------------
@@ -129,10 +120,10 @@ public:
&backupHandle,
errorMessage,
1000))
- throw FileError(wxString(_("Error starting Volume Shadow Copy Service!")) + wxT("\n") +
- wxT("(") + errorMessage + wxT(" Volume: \"") + volumeNameFormatted.c_str() + wxT("\")"));
+ throw FileError(_("Error starting Volume Shadow Copy Service!") + "\n" +
+ "(" + errorMessage + " Volume: \"" + volumeNameFormatted + "\")");
- shadowVol = Zstring(shadowVolName) + common::FILE_NAME_SEPARATOR; //shadowVolName NEVER has a trailing backslash
+ shadowVol = Zstring(shadowVolName) + FILE_NAME_SEPARATOR; //shadowVolName NEVER has a trailing backslash
}
~ShadowVolume()
@@ -172,19 +163,19 @@ Zstring ShadowCopy::makeShadowCopy(const Zstring& inputFile)
if (!::GetVolumePathName(inputFile.c_str(), //__in LPCTSTR lpszFileName,
volumeNameRaw, //__out LPTSTR lpszVolumePathName,
1000)) //__in DWORD cchBufferLength
- throw FileError(wxString(_("Could not determine volume name for file:")) + wxT("\n\"") + zToWx(inputFile) + wxT("\""));
+ throw FileError(_("Could not determine volume name for file:") + "\n\"" + inputFile + "\"");
Zstring volumeNameFormatted = volumeNameRaw;
- if (!volumeNameFormatted.EndsWith(common::FILE_NAME_SEPARATOR))
- volumeNameFormatted += common::FILE_NAME_SEPARATOR;
+ if (!volumeNameFormatted.EndsWith(FILE_NAME_SEPARATOR))
+ volumeNameFormatted += FILE_NAME_SEPARATOR;
//input file is always absolute! directory formatting takes care of this! Therefore volume name can always be found.
const size_t pos = inputFile.find(volumeNameFormatted); //inputFile needs NOT to begin with volumeNameFormatted: consider for example \\?\ prefix!
if (pos == Zstring::npos)
{
- wxString msg = _("Volume name %x not part of filename %y!");
- msg.Replace(wxT("%x"), wxString(wxT("\"")) + zToWx(volumeNameFormatted) + wxT("\""), false);
- msg.Replace(wxT("%y"), wxString(wxT("\"")) + zToWx(inputFile) + wxT("\""), false);
+ std::wstring msg = _("Volume name %x not part of filename %y!");
+ replace(msg, L"%x", std::wstring(L"\"") + volumeNameFormatted + "\"", false);
+ replace(msg, L"%y", std::wstring(L"\"") + inputFile + "\"", false);
throw FileError(msg);
}
bgstack15