#include "csync.h"
#include "vio/csync_vio_local.h"
#include "common/filesystembase.h"
+#include "common/utility.h"
#include <QtCore/QLoggingCategory>
QString path; // Always ends with '\'
};
-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) {
QScopedPointer<csync_vio_handle_t> handle(new csync_vio_handle_t{});
file_stat->size = (handle->ffd.nFileSizeHigh * ((int64_t)(MAXDWORD)+1)) + handle->ffd.nFileSizeLow;
file_stat->modtime = FileTimeToUnixTime(&handle->ffd.ftLastWriteTime, &rem);
- QString fullPath;
- fullPath.reserve(handle->path.size() + std::wcslen(handle->ffd.cFileName));
- fullPath += handle->path; // path always ends with '\', by construction
- fullPath += QString::fromWCharArray(handle->ffd.cFileName);
+ // path always ends with '\', by construction
- if (_csync_vio_local_stat_mb(fullPath, file_stat.get()) < 0) {
+ if (csync_vio_local_stat(handle->path + QString::fromWCharArray(handle->ffd.cFileName), file_stat.get()) < 0) {
// Will get excluded by _csync_detect_update.
file_stat->type = ItemTypeSkip;
}
return file_stat;
}
-
int csync_vio_local_stat(const QString &uri, csync_file_stat_t *buf)
-{
- int rc = _csync_vio_local_stat_mb(uri, buf);
- return rc;
-}
-
-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;
- 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 );
+ h = CreateFileW(reinterpret_cast<const wchar_t *>(OCC::FileSystem::longWinPath(uri).utf16()), 0, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE,
+ NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
+ NULL);
if( h == INVALID_HANDLE_VALUE ) {
- qCCritical(lcCSyncVIOLocal) << "CreateFileW failed on" << longPath;
errno = GetLastError();
+ qCCritical(lcCSyncVIOLocal) << "CreateFileW failed on" << uri << OCC::Utility::formatWinError(errno);
return -1;
}
if(!GetFileInformationByHandle( h, &fileInfo ) ) {
- qCCritical(lcCSyncVIOLocal) << "GetFileInformationByHandle failed on" << longPath;
errno = GetLastError();
+ qCCritical(lcCSyncVIOLocal) << "GetFileInformationByHandle failed on" << uri << OCC::Utility::formatWinError(errno);
CloseHandle(h);
return -1;
}