mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 06:45:49 +03:00
Win: Move hresultToQString from vfs plugin to Utility::formatWinError
This commit is contained in:
parent
4589772393
commit
7fa7bc54c4
3 changed files with 16 additions and 9 deletions
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "filesystembase.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
|
@ -140,13 +141,7 @@ bool FileSystem::rename(const QString &originFileName,
|
|||
(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
|
||||
|
|
|
@ -249,6 +249,8 @@ namespace Utility {
|
|||
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
|
||||
|
|
|
@ -17,12 +17,16 @@
|
|||
*/
|
||||
|
||||
#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)";
|
||||
|
@ -334,4 +338,10 @@ void Utility::UnixTimeToLargeIntegerFiletime(time_t t, LARGE_INTEGER *hundredNSe
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue