Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-02-17 14:06:05 +0300
committerHannah von Reth <vonreth@kde.org>2021-02-19 15:31:23 +0300
commit6d5397babd7f615cf52d8da173c8c1a989b4129b (patch)
tree15344ea320c5ebc140695e4f7fbb0d17cdd6b67c /src
parent3b3a57a62b090cbbbecb8b1e4de8fe5885d06fce (diff)
Use longWinPath in more places
Diffstat (limited to 'src')
-rw-r--r--src/common/filesystembase.cpp16
-rw-r--r--src/common/utility.cpp3
-rw-r--r--src/libsync/owncloudpropagator.cpp4
3 files changed, 9 insertions, 14 deletions
diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp
index 4d8ada561..d73ef4b86 100644
--- a/src/common/filesystembase.cpp
+++ b/src/common/filesystembase.cpp
@@ -204,14 +204,8 @@ bool FileSystem::uncheckedRenameReplace(const QString &originFileName,
(wchar_t *)dest.utf16(),
MOVEFILE_REPLACE_EXISTING + MOVEFILE_COPY_ALLOWED + MOVEFILE_WRITE_THROUGH);
if (!ok) {
- wchar_t *string = 0;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, ::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&string, 0, NULL);
-
- *errorString = QString::fromWCharArray(string);
+ *errorString = Utility::formatWinError(GetLastError());
qCWarning(lcFileSystem) << "Renaming temp file to final failed: " << *errorString;
- LocalFree((HLOCAL)string);
return false;
}
#endif
@@ -447,13 +441,13 @@ bool FileSystem::moveToTrash(const QString &fileName, QString *errorString)
bool FileSystem::isFileLocked(const QString &fileName)
{
#ifdef Q_OS_WIN
- const wchar_t *wuri = reinterpret_cast<const wchar_t *>(fileName.utf16());
// Check if file exists
- DWORD attr = GetFileAttributesW(wuri);
+ const QString fName = longWinPath(fileName);
+ DWORD attr = GetFileAttributesW(reinterpret_cast<const wchar_t *>(fName.utf16()));
if (attr != INVALID_FILE_ATTRIBUTES) {
// Try to open the file with as much access as possible..
HANDLE win_h = CreateFileW(
- wuri,
+ reinterpret_cast<const wchar_t *>(fName.utf16()),
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING,
@@ -483,7 +477,7 @@ bool FileSystem::isJunction(const QString &filename)
{
#ifdef Q_OS_WIN
WIN32_FIND_DATA findData;
- HANDLE hFind = FindFirstFileEx((const wchar_t *)filename.utf16(), FindExInfoBasic, &findData, FindExSearchNameMatch, NULL, 0);
+ HANDLE hFind = FindFirstFileEx(reinterpret_cast<const wchar_t *>(longWinPath(filename).utf16()), FindExInfoBasic, &findData, FindExSearchNameMatch, NULL, 0);
if (hFind != INVALID_HANDLE_VALUE) {
FindClose(hFind);
return false;
diff --git a/src/common/utility.cpp b/src/common/utility.cpp
index d0dc3d018..b800c7ef8 100644
--- a/src/common/utility.cpp
+++ b/src/common/utility.cpp
@@ -19,6 +19,7 @@
#include "config.h"
#include "common/utility.h"
+#include "common/filesystembase.h"
#include "version.h"
// Note: This file must compile without QtGui
@@ -222,7 +223,7 @@ qint64 Utility::freeDiskSpace(const QString &path)
#elif defined(Q_OS_WIN)
ULARGE_INTEGER freeBytes;
freeBytes.QuadPart = 0L;
- if (GetDiskFreeSpaceEx(reinterpret_cast<const wchar_t *>(path.utf16()), &freeBytes, NULL, NULL)) {
+ if (GetDiskFreeSpaceEx(reinterpret_cast<const wchar_t *>(FileSystem::longWinPath(path).utf16()), &freeBytes, NULL, NULL)) {
return freeBytes.QuadPart;
}
#endif
diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp
index cd87a3ef0..317258560 100644
--- a/src/libsync/owncloudpropagator.cpp
+++ b/src/libsync/owncloudpropagator.cpp
@@ -535,7 +535,7 @@ bool OwncloudPropagator::localFileNameClash(const QString &relFile)
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
- hFind = FindFirstFileW((wchar_t *)file.utf16(), &FindFileData);
+ hFind = FindFirstFileW(reinterpret_cast<const wchar_t *>(FileSystem::longWinPath(file).utf16()), &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) {
// returns false.
} else {
@@ -569,7 +569,7 @@ bool OwncloudPropagator::hasCaseClashAccessibilityProblem(const QString &relfile
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
- hFind = FindFirstFileW(reinterpret_cast<const wchar_t *>(file.utf16()), &FindFileData);
+ hFind = FindFirstFileW(reinterpret_cast<const wchar_t *>(FileSystem::longWinPath(file).utf16()), &FindFileData);
if (hFind != INVALID_HANDLE_VALUE) {
QString firstFile = QString::fromWCharArray(FindFileData.cFileName);
if (FindNextFile(hFind, &FindFileData)) {