QString path; // Always ends with '\'
};
-static int _csync_vio_local_stat_mb(const mbchar_t *uri, csync_file_stat_t *buf);
+static int _csync_vio_local_stat_mb(const QString &path, csync_file_stat_t *buf);
csync_vio_handle_t *csync_vio_local_opendir(const QString &name) {
file_stat->size = (handle->ffd.nFileSizeHigh * ((int64_t)(MAXDWORD)+1)) + handle->ffd.nFileSizeLow;
file_stat->modtime = FileTimeToUnixTime(&handle->ffd.ftLastWriteTime, &rem);
- std::wstring fullPath;
+ QString fullPath;
fullPath.reserve(handle->path.size() + std::wcslen(handle->ffd.cFileName));
- fullPath += handle->path.toStdWString(); // path always ends with '\', by construction
- fullPath += handle->ffd.cFileName;
+ fullPath += handle->path; // path always ends with '\', by construction
+ fullPath += QString::fromWCharArray(handle->ffd.cFileName);
- if (_csync_vio_local_stat_mb(fullPath.data(), file_stat.get()) < 0) {
+ if (_csync_vio_local_stat_mb(fullPath, file_stat.get()) < 0) {
// Will get excluded by _csync_detect_update.
file_stat->type = ItemTypeSkip;
}
int csync_vio_local_stat(const QString &uri, csync_file_stat_t *buf)
{
- const std::wstring wuri = uri.toStdWString();
- int rc = _csync_vio_local_stat_mb(wuri.data(), buf);
+ int rc = _csync_vio_local_stat_mb(uri, buf);
return rc;
}
-static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf)
+static int _csync_vio_local_stat_mb(const QString &path, csync_file_stat_t *buf)
{
/* Almost nothing to do since csync_vio_local_readdir already filled up most of the information
But we still need to fetch the file ID.
BY_HANDLE_FILE_INFORMATION fileInfo;
ULARGE_INTEGER FileIndex;
- h = CreateFileW( wuri, 0, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE,
+ const auto longPath = OCC::FileSystem::longWinPath(path);
+
+ h = CreateFileW(longPath.toStdWString().data(), 0, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE,
nullptr, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
nullptr );
if( h == INVALID_HANDLE_VALUE ) {
- qCCritical(lcCSyncVIOLocal, "CreateFileW failed on %ls", wuri);
+ qCCritical(lcCSyncVIOLocal) << "CreateFileW failed on" << longPath;
errno = GetLastError();
return -1;
}
if(!GetFileInformationByHandle( h, &fileInfo ) ) {
- qCCritical(lcCSyncVIOLocal, "GetFileInformationByHandle failed on %ls", wuri);
+ qCCritical(lcCSyncVIOLocal) << "GetFileInformationByHandle failed on" << longPath;
errno = GetLastError();
CloseHandle(h);
return -1;
#include "cfapiwrapper.h"
#include "common/utility.h"
+#include "common/filesystembase.h"
#include "hydrationjob.h"
#include "vfs_cfapi.h"
OCC::CfApiWrapper::FileHandle OCC::CfApiWrapper::handleForPath(const QString &path)
{
+ if (path.isEmpty()) {
+ return {};
+ }
+
if (QFileInfo(path).isDir()) {
HANDLE handle = nullptr;
const qint64 openResult = CfOpenFileWithOplock(path.toStdWString().data(), CF_OPEN_FILE_FLAG_NONE, &handle);
return {handle, [](HANDLE h) { CfCloseHandle(h); }};
}
} else {
- const auto handle = CreateFile(path.toStdWString().data(), 0, 0, nullptr,
+ const auto longpath = OCC::FileSystem::longWinPath(path);
+ const auto handle = CreateFile(longpath.toStdWString().data(), 0, 0, nullptr,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (handle != INVALID_HANDLE_VALUE) {
return {handle, [](HANDLE h) { CloseHandle(h); }};
+ } else {
+ qCCritical(lcCfApiWrapper) << "Could not CreateFile for longpath:" << longpath << "with error:" << GetLastError();
}
}