From d26884efd9f1d0295972f57e5ffe1ff2c10ce55e Mon Sep 17 00:00:00 2001 From: James Harper Date: Thu, 30 Oct 2008 09:15:49 +0000 Subject: [PATCH] fixed bug on restore due to mingw handling of wide strings. tuned debugging values slightly. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7945 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/win32/filed/plugins/file_node.c | 9 ++++++--- bacula/src/win32/filed/plugins/storage_group_node.c | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bacula/src/win32/filed/plugins/file_node.c b/bacula/src/win32/filed/plugins/file_node.c index 6af291d130..a200faf1cf 100644 --- a/bacula/src/win32/filed/plugins/file_node.c +++ b/bacula/src/win32/filed/plugins/file_node.c @@ -111,13 +111,15 @@ file_node_t::pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io) { HRESULT result; HANDLE handle; + char *tmp = new char[wcslen(filename) + 1]; + wcstombs(tmp, filename, wcslen(filename) + 1); - _DebugMessage(100, "pluginIoOpen_FILE - filename = %S\n", filename); + _DebugMessage(0, "pluginIoOpen_FILE - filename = %s\n", tmp); io->status = 0; io->io_errno = 0; if (context->job_type == JOB_TYPE_BACKUP) { - _DebugMessage(100, "Calling HrESEBackupOpenFile\n"); + _DebugMessage(10, "Calling HrESEBackupOpenFile\n"); result = HrESEBackupOpenFile(hccx, filename, 65535, 1, &backup_file_handle, §ion_size); if (result) { @@ -129,11 +131,12 @@ file_node_t::pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io) } else { - _DebugMessage(100, "Calling HrESERestoreOpenFile\n"); + _DebugMessage(10, "Calling HrESERestoreOpenFile for '%s'\n", tmp); result = HrESERestoreOpenFile(hccx, filename, 1, &restore_file_handle); if (result == hrRestoreAtFileLevel) { restore_at_file_level = true; + _DebugMessage(100, "Calling CreateFileW for '%s'\n", tmp); handle = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (handle == INVALID_HANDLE_VALUE) { diff --git a/bacula/src/win32/filed/plugins/storage_group_node.c b/bacula/src/win32/filed/plugins/storage_group_node.c index d6c453ed9e..b9f111a80e 100644 --- a/bacula/src/win32/filed/plugins/storage_group_node.c +++ b/bacula/src/win32/filed/plugins/storage_group_node.c @@ -171,7 +171,6 @@ storage_group_node_t::startBackupFile(exchange_fd_context_t *context, struct sav if (!include_file) { tmp_time = (((int64_t)modified_time.dwHighDateTime) << 32) | modified_time.dwLowDateTime; - //FIXME: this is too big according to mingw tmp_time -= 116444736000000000LL; tmp_time /= 10000000; if (tmp_time > context->job_since) @@ -413,8 +412,9 @@ storage_group_node_t::createFile(exchange_fd_context_t *context, struct restore_ } len = wcslen(restore_environment->m_wszRestoreLogPath) + strlen(file_node->name + i) + 1 + 1; file_node->filename = new WCHAR[len]; - // FIXME: %S not supported under mingw - //swprintf(file_node->filename, len, L"%s\\%S", restore_environment->m_wszRestoreLogPath, file_node->name + i); + wcscpy(file_node->filename, restore_environment->m_wszRestoreLogPath); + wcscat(file_node->filename, L"\\"); + mbstowcs(&file_node->filename[wcslen(file_node->filename)], file_node->name + i, strlen(file_node->name + i) + 1); context->current_node = file_node; return bRC_OK; case 3: -- 2.39.5