support unicode compiling

This commit is contained in:
spyhole 2004-10-13 12:55:13 +00:00
parent 46ec7cbf38
commit 3a888c84b5
1 changed files with 17 additions and 1 deletions

View File

@ -60,7 +60,12 @@ namespace
{
char *buffer=0;
int err = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, err, 0, (LPWSTR)(LPCSTR)&buffer, 0, 0);
#ifdef _UNICODE
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, err, 0, (LPWSTR)(LPCSTR)&buffer, 0, 0);
#else
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, err, 0, (LPSTR)&buffer, 0, 0);
#endif
auto_LocalFree auto_free(buffer); // needed for exception safety
std::stringstream s;
@ -106,6 +111,7 @@ namespace libtorrent
assert(access_mask & (GENERIC_READ | GENERIC_WRITE));
#ifdef _UNICODE
HANDLE new_handle = CreateFile(
(LPCWSTR)file_name
, access_mask
@ -114,6 +120,16 @@ namespace libtorrent
, (flags & read_flag)?OPEN_EXISTING:OPEN_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, 0);
#else
HANDLE new_handle = CreateFile(
file_name
, access_mask
, FILE_SHARE_READ
, 0
, (flags & read_flag)?OPEN_EXISTING:OPEN_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, 0);
#endif
if (new_handle == INVALID_HANDLE_VALUE)
{