diff --git a/src/core/global.h b/src/core/global.h --- a/src/core/global.h +++ b/src/core/global.h @@ -248,6 +248,7 @@ ERR_CANNOT_CREATE_SLAVE = KJob::UserDefinedError + 73, ///< used by Slave::createSlave, @since 5.30 ERR_FILE_TOO_LARGE_FOR_FAT32 = KJob::UserDefinedError + 74, ///< @since 5.54 ERR_OWNER_DIED = KJob::UserDefinedError + 75, ///< Value used between kuiserver and views when the job owner disappears unexpectedly. It should not be emitted by slaves. @since 5.54 + ERR_CANNOT_MKDIR_CONTAINING_SLASH = KJob::UserDefinedError + 76, ///< A specific error for the mkdir job failing due to presence of slashes in the directory names. @since 5.55 }; /** diff --git a/src/core/job_error.cpp b/src/core/job_error.cpp --- a/src/core/job_error.cpp +++ b/src/core/job_error.cpp @@ -248,6 +248,9 @@ case KIO::ERR_FILE_TOO_LARGE_FOR_FAT32: result = xi18nc("@info", "Cannot transfer %1 because it is too large. The destination filesystem only supports files up to 4GB", errorText); break; + case KIO::ERR_CANNOT_MKDIR_CONTAINING_SLASH: + result = xi18nc("@info", "Cannot create %1 because slashes are not allowed in file and folder names.", errorText); + break; default: result = i18n("Unknown error code %1\n%2\nPlease send a full bug report at https://bugs.kde.org.", errorCode, errorText); break; @@ -1078,6 +1081,12 @@ solutions << i18n("Reformat the destination drive to use a filesystem that supports files that large."); break; + case ERR_CANNOT_MKDIR_CONTAINING_SLASH: + errorName = xi18nc("@info", "Cannot create %1", errorText); + description = xi18nc("@info", "Cannot create %1 because slashes are not allowed in file and folder names.", errorText); + solutions << i18n("Do not use slashes in file/folder names."); + break; + default: // fall back to the plain error... errorName = i18n("Undocumented Error"); diff --git a/src/ioslaves/file/file.cpp b/src/ioslaves/file/file.cpp --- a/src/ioslaves/file/file.cpp +++ b/src/ioslaves/file/file.cpp @@ -283,6 +283,14 @@ { const QString path(url.toLocalFile()); +#ifndef Q_OS_WIN + // UNIX does not allow identifiers containing / + if (path.contains(QLatin1Char('/'))) { + error(KIO::ERR_CANNOT_MKDIR_CONTAINING_SLASH, path); + return; + } +#endif + // qDebug() << path << "permission=" << permissions; // Remove existing file or symlink, if requested (#151851)