Skip to content

Commit

Permalink
fix: bypass Qt's QFile::encodeName() in csync
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Jan 23, 2025
1 parent 7e67256 commit 6655b26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/csync/std/c_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@

#include "common/filesystembase.h"

#include <QFile>

#ifdef HAVE_UTIMES
int c_utimes(const QString &uri, const struct timeval *times) {
int ret = utimes(QFile::encodeName(uri).constData(), times);
int ret = utimes(uri.toLocal8Bit().constData(), times);
return ret;
}
#else // HAVE_UTIMES
Expand Down
15 changes: 12 additions & 3 deletions src/csync/vio/csync_vio_local_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ struct csync_vio_handle_t {
QString path;
};

QByteArray csync_encode_name(const QString &fileName)
{
return fileName.toLocal8Bit();
}
static QString csync_decode_name(const char *localFileName)
{
return QString::fromLocal8Bit(localFileName);
}

csync_vio_handle_t *csync_vio_local_opendir(const QString &name) {
std::unique_ptr<csync_vio_handle_t> handle(new csync_vio_handle_t{});

auto dirname = QFile::encodeName(name);
auto dirname = csync_encode_name(name);

handle->dh = opendir(dirname.constData());
if (!handle->dh) {
Expand Down Expand Up @@ -77,7 +86,7 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *h
} while (qstrcmp(dirent->d_name, ".") == 0 || qstrcmp(dirent->d_name, "..") == 0);

file_stat.reset(new csync_file_stat_t);
file_stat->path = QFile::decodeName(dirent->d_name);
file_stat->path = csync_decode_name(dirent->d_name);

/* Check for availability of d_type, see manpage. */
#if defined(_DIRENT_HAVE_D_TYPE) || defined(__APPLE__)
Expand Down Expand Up @@ -120,7 +129,7 @@ int csync_vio_local_stat(const QString &uri, csync_file_stat_t *buf)
{
struct stat sb;

if (lstat(QFile::encodeName(uri).constData(), &sb) < 0) {
if (lstat(csync_encode_name(uri).constData(), &sb) < 0) {
return -1;
}

Expand Down

0 comments on commit 6655b26

Please sign in to comment.