Changeset View
Changeset View
Standalone View
Standalone View
src/ioslaves/file/file.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
72 | #if HAVE_VOLMGT | 72 | #if HAVE_VOLMGT | ||
73 | #include <volmgt.h> | 73 | #include <volmgt.h> | ||
74 | #include <sys/mnttab.h> | 74 | #include <sys/mnttab.h> | ||
75 | #endif | 75 | #endif | ||
76 | 76 | | |||
77 | #include <kdirnotify.h> | 77 | #include <kdirnotify.h> | ||
78 | #include <ioslave_defaults.h> | 78 | #include <ioslave_defaults.h> | ||
79 | 79 | | |||
80 | #include "fdreceiver.h" | | |||
81 | | ||||
82 | Q_LOGGING_CATEGORY(KIO_FILE, "kf5.kio.kio_file") | 80 | Q_LOGGING_CATEGORY(KIO_FILE, "kf5.kio.kio_file") | ||
83 | 81 | | |||
84 | // Pseudo plugin class to embed meta data | 82 | // Pseudo plugin class to embed meta data | ||
85 | class KIOPluginForMetaData : public QObject | 83 | class KIOPluginForMetaData : public QObject | ||
86 | { | 84 | { | ||
87 | Q_OBJECT | 85 | Q_OBJECT | ||
88 | Q_PLUGIN_METADATA(IID "org.kde.kio.slave.file" FILE "file.json") | 86 | Q_PLUGIN_METADATA(IID "org.kde.kio.slave.file" FILE "file.json") | ||
89 | }; | 87 | }; | ||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Line(s) | 287 | { | |||
295 | if (metaData(QStringLiteral("overwrite")) == QLatin1String("true")) { | 293 | if (metaData(QStringLiteral("overwrite")) == QLatin1String("true")) { | ||
296 | if (!QFile::remove(path)) { | 294 | if (!QFile::remove(path)) { | ||
297 | execWithElevatedPrivilege(DEL, path); | 295 | execWithElevatedPrivilege(DEL, path); | ||
298 | } | 296 | } | ||
299 | } | 297 | } | ||
300 | 298 | | |||
301 | QT_STATBUF buff; | 299 | QT_STATBUF buff; | ||
302 | if (QT_LSTAT(QFile::encodeName(path).constData(), &buff) == -1) { | 300 | if (QT_LSTAT(QFile::encodeName(path).constData(), &buff) == -1) { | ||
303 | bool dirCreated; | 301 | bool dirCreated = QDir().mkdir(path); | ||
304 | if (!(dirCreated = QDir().mkdir(path))) { | 302 | if (!dirCreated) { | ||
305 | if (auto err = execWithElevatedPrivilege(MKDIR, path)) { | 303 | if (auto err = execWithElevatedPrivilege(MKDIR, path)) { | ||
306 | if (!err.wasCanceled()) { | 304 | if (!err.wasCanceled()) { | ||
307 | //TODO: add access denied & disk full (or another reasons) handling (into Qt, possibly) | 305 | //TODO: add access denied & disk full (or another reasons) handling (into Qt, possibly) | ||
308 | error(KIO::ERR_CANNOT_MKDIR, path); | 306 | error(KIO::ERR_CANNOT_MKDIR, path); | ||
309 | } | 307 | } | ||
310 | return; | 308 | return; | ||
311 | } | 309 | } | ||
312 | dirCreated = true; | 310 | dirCreated = true; | ||
▲ Show 20 Lines • Show All 355 Lines • ▼ Show 20 Line(s) | 662 | if (!err.wasCanceled()) { | |||
668 | if (f.error() == QFileDevice::PermissionsError) { | 666 | if (f.error() == QFileDevice::PermissionsError) { | ||
669 | error(KIO::ERR_WRITE_ACCESS_DENIED, dest); | 667 | error(KIO::ERR_WRITE_ACCESS_DENIED, dest); | ||
670 | } else { | 668 | } else { | ||
671 | error(KIO::ERR_CANNOT_OPEN_FOR_WRITING, dest); | 669 | error(KIO::ERR_CANNOT_OPEN_FOR_WRITING, dest); | ||
672 | } | 670 | } | ||
673 | } | 671 | } | ||
674 | return; | 672 | return; | ||
675 | } else { | 673 | } else { | ||
674 | #ifndef Q_OS_WIN | ||||
676 | if ((_flags & KIO::Resume)) { | 675 | if ((_flags & KIO::Resume)) { | ||
677 | execWithElevatedPrivilege(CHOWN, dest, getuid(), getgid()); | 676 | execWithElevatedPrivilege(CHOWN, dest, getuid(), getgid()); | ||
678 | QFile::setPermissions(dest, modeToQFilePermissions(filemode)); | 677 | QFile::setPermissions(dest, modeToQFilePermissions(filemode)); | ||
679 | } | 678 | } | ||
679 | #endif | ||||
680 | } | 680 | } | ||
681 | } | 681 | } | ||
682 | } | 682 | } | ||
683 | 683 | | |||
684 | if (f.write(buffer) == -1) { | 684 | if (f.write(buffer) == -1) { | ||
685 | if (f.error() == QFile::ResourceError) { // disk full | 685 | if (f.error() == QFile::ResourceError) { // disk full | ||
686 | error(KIO::ERR_DISK_FULL, dest_orig); | 686 | error(KIO::ERR_DISK_FULL, dest_orig); | ||
687 | result = -2; // means: remove dest file | 687 | result = -2; // means: remove dest file | ||
▲ Show 20 Lines • Show All 763 Lines • Show Last 20 Lines |