diff options
author | Chris Wilson <chris+github@qwirx.com> | 2011-04-06 20:53:52 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2011-04-06 20:53:52 +0000 |
commit | d22fc3f49b5c1d1e1ccf0d250d7123b1a281dc18 (patch) | |
tree | f861dfa5cfef0b8a4163b7f8e304a9474c44d0f3 /lib/win32 | |
parent | e51e14397af27d3a19e4e56a82be78046352ec90 (diff) |
Add VSS: prefix to VSS log messages.
Start a snapshot set and add backup locations as volumes.
Modularise IVssAsync waiting code.
Diffstat (limited to 'lib/win32')
-rw-r--r-- | lib/win32/emu.cpp | 63 | ||||
-rw-r--r-- | lib/win32/emu.h | 3 |
2 files changed, 66 insertions, 0 deletions
diff --git a/lib/win32/emu.cpp b/lib/win32/emu.cpp index 4b7a1b15..0afb9fa3 100644 --- a/lib/win32/emu.cpp +++ b/lib/win32/emu.cpp @@ -284,6 +284,69 @@ char* ConvertFromWideString(const WCHAR* pString, unsigned int codepage) return buffer; } +bool ConvertFromWideString(const std::wstring& rInput, + std::string* pOutput, unsigned int codepage) +{ + int len = WideCharToMultiByte + ( + codepage, // destination code page + 0, // character-type options + rInput.c_str(), // string to map + rInput.size(), // number of bytes in string - auto detect + NULL, // output buffer + 0, // size of buffer - work out + // how much space we need + NULL, // replace unknown chars with system default + NULL // don't tell us when that happened + ); + + if (len == 0) + { + ::syslog(LOG_WARNING, + "Failed to convert wide string to narrow: " + "error %d", GetLastError()); + errno = EINVAL; + return false; + } + + char* buffer = new char[len]; + + if (buffer == NULL) + { + ::syslog(LOG_WARNING, + "Failed to convert wide string to narrow: " + "out of memory"); + errno = ENOMEM; + return false; + } + + len = WideCharToMultiByte + ( + codepage, // source code page + 0, // character-type options + rInput.c_str(), // string to map + rInput.size(), // number of bytes in string - auto detect + buffer, // output buffer + len, // size of buffer + NULL, // replace unknown chars with system default + NULL // don't tell us when that happened + ); + + if (len == 0) + { + ::syslog(LOG_WARNING, + "Failed to convert wide string to narrow: " + "error %i", GetLastError()); + errno = EACCES; + delete [] buffer; + return false; + } + + *pOutput = std::string(buffer, len); + delete [] buffer; + return true; +} + // -------------------------------------------------------------------------- // // Function diff --git a/lib/win32/emu.h b/lib/win32/emu.h index e398d5f6..b7aa5d47 100644 --- a/lib/win32/emu.h +++ b/lib/win32/emu.h @@ -423,6 +423,9 @@ bool ConvertFromUtf8 (const std::string& rSource, std::string& rDest, bool ConvertUtf8ToConsole(const std::string& rSource, std::string& rDest); bool ConvertConsoleToUtf8(const std::string& rSource, std::string& rDest); char* ConvertFromWideString(const WCHAR* pString, unsigned int codepage); +bool ConvertFromWideString(const std::wstring& rInput, + std::string* pOutput, unsigned int codepage); +std::string ConvertPathToAbsoluteUnicode(const char *pFileName); // Utility function which returns a default config file name, // based on the path of the current executable. |