*/
#include "filesystembase.h"
+#include "utility.h"
#include <QDateTime>
#include <QDir>
(wchar_t *)dest.utf16(),
MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH);
if (!success) {
- wchar_t *string = 0;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- nullptr, ::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&string, 0, nullptr);
-
- error = QString::fromWCharArray(string);
- LocalFree((HLOCAL)string);
+ error = Utility::formatWinError();
}
} else
#endif
OCSYNC_EXPORT void FiletimeToLargeIntegerFiletime(FILETIME *filetime, LARGE_INTEGER *hundredNSecs);
OCSYNC_EXPORT void UnixTimeToLargeIntegerFiletime(time_t t, LARGE_INTEGER *hundredNSecs);
+ OCSYNC_EXPORT QString formatWinError(long error = GetLastError());
+
#endif
}
/** @} */ // \addtogroup
*/
#include "asserts.h"
+#include "utility.h"
+
+#include <comdef.h>
+#include <shlguid.h>
#include <shlobj.h>
+#include <string>
#include <winbase.h>
#include <windows.h>
#include <winerror.h>
-#include <shlguid.h>
-#include <string>
+
#include <QLibrary>
static const char systemRunPathC[] = R"(HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run)";
hundredNSecs->HighPart = ll >>32;
}
+
+QString Utility::formatWinError(long errorCode)
+{
+ return QStringLiteral("WindowsError: %1: %2").arg(QString::number(errorCode), QString::fromWCharArray(_com_error(errorCode).ErrorMessage()));
+}
+
} // namespace OCC